]>
git.immae.eu Git - perso/Immae/Config/Nix.git/blob - modules/private/ftp_sync.sh
5 LDAP_BIND
="cn=ssh,ou=services,dc=immae,dc=eu"
6 LDAP_PASS
=$(cat /etc/ssh/ldap_password)
7 LDAP_HOST
="ldap.immae.eu"
8 LDAP_BASE
="dc=immae,dc=eu"
9 LDAP_FILTER
="(memberOf=cn=users,cn=ftp,ou=services,dc=immae,dc=eu)"
14 if [ -n "$uids" ]; then
16 echo "$keys" | while read key
; do
17 if [ -n "$key" ]; then
18 ssh-keygen -e -f <(echo "$key")
20 done > /var
/lib
/proftpd
/authorized_keys
/$uid
25 mkdir -p /var
/lib
/proftpd
/authorized_keys
28 if [[ "$i" =~ ^dn
: ]]; then
29 handle_keys
"$uids" "$keys"
33 if [[ "$i" =~ ^uid
: ]]; then
34 uids
="$uids ${i#uid: }"
36 if [[ "$i" =~ ^immaeSshKey
: ]]; then
37 key
="${i#immaeSshKey: }"
38 if [[ "$key" =~ ^
ssh- ]]; then
41 elif echo "$key" | cut
-d" " -f1 | grep -q "\bftp\b"; then
43 $(echo "$key" | cut -d" " -f2-)"
46 done < <(ldapsearch
-h "$LDAP_HOST" -ZZ -LLL -D "$LDAP_BIND" -w "$LDAP_PASS" -b "$LDAP_BASE" -x -o ldif
-wrap=no
"$LDAP_FILTER" uid immaeSshKey
)
47 handle_keys
"$uids" "$keys"