aboutsummaryrefslogtreecommitdiff
path: root/modules/private/ssh/ldap_authorized_keys.sh
diff options
context:
space:
mode:
Diffstat (limited to 'modules/private/ssh/ldap_authorized_keys.sh')
-rwxr-xr-xmodules/private/ssh/ldap_authorized_keys.sh52
1 files changed, 0 insertions, 52 deletions
diff --git a/modules/private/ssh/ldap_authorized_keys.sh b/modules/private/ssh/ldap_authorized_keys.sh
deleted file mode 100755
index 402f283..0000000
--- a/modules/private/ssh/ldap_authorized_keys.sh
+++ /dev/null
@@ -1,52 +0,0 @@
1#!/usr/bin/env bash
2
3LDAPSEARCH=ldapsearch
4KEY="immaeSshKey"
5LDAP_BIND="cn=ssh,ou=services,dc=immae,dc=eu"
6LDAP_PASS=$(cat /etc/ssh/ldap_password)
7LDAP_HOST="ldap.immae.eu"
8LDAP_BASE="dc=immae,dc=eu"
9
10suitable_for() {
11 type_for="$1"
12 key="$2"
13
14 if [[ $key != *$'\n'* ]] && [[ $key == ssh-* ]]; then
15 echo "$key"
16 else
17 key_type=$(cut -d " " -f 1 <<< "$key")
18
19 if grep -q "\b-$type_for\b" <<< "$key_type"; then
20 echo ""
21 elif grep -q "\b$type_for\b" <<< "$key_type"; then
22 echo $(sed -e "s/^[^ ]* //g" <<< "$key")
23 else
24 echo ""
25 fi
26 fi
27}
28
29clean_key_line() {
30 type_for="$1"
31 line="$2"
32
33 if [[ "$line" == $KEY::* ]]; then
34 # base64 keys should't happen, unless wrong copy-pasting
35 key=""
36 else
37 key=$(sed -e "s/^$KEY: *//" -e "s/ *$//" <<< "$line")
38 fi
39
40 suitable_for "$type_for" "$key"
41}
42
43ldap_search() {
44 $LDAPSEARCH -h $LDAP_HOST -ZZ -b $LDAP_BASE -D $LDAP_BIND -w "$LDAP_PASS" -x -o ldif-wrap=no -LLL "$@"
45}
46
47ldap_keys() {
48 user=$1;
49 @snippets@
50}
51
52ldap_keys $@