This commit is contained in:
Pavel Guzaev
2024-03-09 17:36:50 +05:00
commit 431b4f5cfd
44 changed files with 3239 additions and 0 deletions

View File

@@ -0,0 +1,16 @@
#!/bin/bash
SSH_USER=$1
LDAP_URI={{ ldap_server }}:{{ ldap_port }}
GROUP_DN={{ base_group }}
BASE_DN={{ base_passwd }}
ldapFilter="(&(shadowInactive=0)(uid=${SSH_USER})(memberOf=cn=users,ou=groups,dc=dc1,dc=com)(sshPublicKey=*))"
# Get "sshPublicKey":
KEY=$(ldapsearch -x -LLL -o ldif-wrap=no -H "${LDAP_URI}" -b "${BASE_DN}" "${ldapFilter}" sshPublicKey | \
grep sshPublicKey | \
perl -MMIME::Base64 -wpe 's/^sshPublicKey(:{1,2}) (.+)$/$1 eq "::" ? decode_base64($2) : $2/e')
echo "${KEY}"
exit 0

View File

@@ -0,0 +1,7 @@
uri {{ ldap_server }}:{{ ldap_port }}/
base {{ ldap_base }}
base group {{ base_group }}
base passwd {{ base_passwd }}
filter group {{ filter_group }}
filter passwd {{ filter_passwd }}
tls_reqcert {{ tls_reqcert }}