diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-10-19 10:26:54 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-10-19 10:26:54 +0200 |
commit | 1b9150a54b5cb0b512265cdcf88ad10c9a4a55b1 (patch) | |
tree | 048eea0830161eda32bdec86a167d9b20050cca2 /modules/private/ssh/ldap_regular.sh | |
parent | b76b1d1f1678e329d0596e4403620f653a763d96 (diff) | |
download | Nix-1b9150a54b5cb0b512265cdcf88ad10c9a4a55b1.tar.gz Nix-1b9150a54b5cb0b512265cdcf88ad10c9a4a55b1.tar.zst Nix-1b9150a54b5cb0b512265cdcf88ad10c9a4a55b1.zip |
Make ssh ldap connection by modules
Diffstat (limited to 'modules/private/ssh/ldap_regular.sh')
-rw-r--r-- | modules/private/ssh/ldap_regular.sh | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/modules/private/ssh/ldap_regular.sh b/modules/private/ssh/ldap_regular.sh new file mode 100644 index 0000000..4c2f47e --- /dev/null +++ b/modules/private/ssh/ldap_regular.sh | |||
@@ -0,0 +1,19 @@ | |||
1 | ### This snippet is not standalone and must be integrated in the global ldap_authorized_keys.sh | ||
2 | LDAP_MEMBER="cn=users,cn=ssh,ou=services,dc=immae,dc=eu" | ||
3 | |||
4 | ldap_search '(&(memberOf='$LDAP_MEMBER')('$KEY'=*)(uid='$user'))' $KEY | \ | ||
5 | while read line ; | ||
6 | do | ||
7 | if [ ! -z "$line" ]; then | ||
8 | if [[ $line == dn* ]]; then | ||
9 | user=$(sed -n 's/.*uid=\([^,]*\).*/\1/p' <<< "$line") | ||
10 | elif [[ $line == $KEY* ]]; then | ||
11 | key=$(clean_key_line ssh "$line") | ||
12 | if [ ! -z "$key" ]; then | ||
13 | if [[ $key != *$'\n'* ]] && [[ $key == ssh-* ]]; then | ||
14 | echo $key | ||
15 | fi | ||
16 | fi | ||
17 | fi | ||
18 | fi | ||
19 | done | ||