aboutsummaryrefslogtreecommitdiff
path: root/modules/private/ssh/ldap_regular.sh
blob: 4c2f47e9cb00bf77f6e52007fece19e8fe351b04 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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