]>
git.immae.eu Git - perso/Immae/Config/Nix.git/blob - flakes/private/ssh/ldap_authorized_keys.sh
5 LDAP_BIND
="cn=ssh,ou=services,dc=immae,dc=eu"
6 LDAP_PASS
=$(cat /etc/ssh/ldap_password)
7 LDAP_HOST
="ldap://ldap.immae.eu"
8 LDAP_BASE
="dc=immae,dc=eu"
9 USER_LDAP_BASE
="ou=users,dc=immae,dc=eu"
13 PSQL_USER
="immae_auth_read"
14 PSQL_PASS
=$(cat /etc/ssh/psql_password)
20 if [[ $key != *$
'\n'* ]] && [[ $key == ssh-* ]]; then
23 key_type
=$(cut -d " " -f 1 <<< "$key")
25 if grep -q "\b-$type_for\b" <<< "$key_type"; then
27 elif grep -q "\b$type_for\b" <<< "$key_type"; then
28 echo $(sed -e "s/^[^ ]* //g" <<< "$key")
39 if [[ "$line" == $KEY::* ]]; then
40 # base64 keys should't happen, unless wrong copy-pasting
43 key
=$(sed -e "s/^$KEY: *//" -e "s/ *$//" <<< "$line")
46 suitable_for
"$type_for" "$key"
50 $LDAPSEARCH -H $LDAP_HOST -ZZ -b $LDAP_BASE -D $LDAP_BIND -w "$LDAP_PASS" -x -o ldif
-wrap=no
-LLL "$@"
54 PGPASSWORD
="$PSQL_PASS" psql
-U "$PSQL_USER" -h "$PSQL_HOST" -X -A -t -d "$PSQL_BASE" -c "$@"