]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - systems/dilion/ssh_ldap_regular.sh
Squash changes containing private information
[perso/Immae/Config/Nix.git] / systems / dilion / ssh_ldap_regular.sh
diff --git a/systems/dilion/ssh_ldap_regular.sh b/systems/dilion/ssh_ldap_regular.sh
new file mode 100644 (file)
index 0000000..4c2f47e
--- /dev/null
@@ -0,0 +1,19 @@
+### This snippet is not standalone and must be integrated in the global ldap_authorized_keys.sh
+LDAP_MEMBER="cn=users,cn=ssh,ou=services,dc=immae,dc=eu"
+
+ldap_search '(&(memberOf='$LDAP_MEMBER')('$KEY'=*)(uid='$user'))' $KEY | \
+  while read line ;
+  do
+    if [ ! -z "$line" ]; then
+      if [[ $line == dn* ]]; then
+        user=$(sed -n 's/.*uid=\([^,]*\).*/\1/p' <<< "$line")
+      elif [[ $line == $KEY* ]]; then
+        key=$(clean_key_line ssh "$line")
+        if [ ! -z "$key" ]; then
+          if [[ $key != *$'\n'* ]] && [[ $key == ssh-* ]]; then
+            echo $key
+          fi
+        fi
+      fi
+    fi
+  done