aboutsummaryrefslogtreecommitdiff
path: root/modules/private/ssh/ldap_authorized_keys.sh
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2023-10-04 01:35:06 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2023-10-04 02:11:48 +0200
commit1a64deeb894dc95e2645a75771732c6cc53a79ad (patch)
tree1b9df4838f894577a09b9b260151756272efeb53 /modules/private/ssh/ldap_authorized_keys.sh
parentfa25ffd4583cc362075cd5e1b4130f33306103f0 (diff)
downloadNix-1a64deeb894dc95e2645a75771732c6cc53a79ad.tar.gz
Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.tar.zst
Nix-1a64deeb894dc95e2645a75771732c6cc53a79ad.zip
Squash changes containing private information
There were a lot of changes since the previous commit, but a lot of them contained personnal information about users. All thos changes got stashed into a single commit (history is kept in a different place) and private information was moved in a separate private repository
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 $@