diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-04 15:25:35 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2023-10-04 16:16:53 +0200 |
commit | 877f7bf7a17f44bd17dd1f0bbfd88abdab67ad72 (patch) | |
tree | c47e5037b7071696a9abfbab2c99281885ce36b5 /flakes/private/ssh | |
parent | ccae7987be59b8a30e98f0429bd78479f6f7c7bc (diff) | |
download | Nix-877f7bf7a17f44bd17dd1f0bbfd88abdab67ad72.tar.gz Nix-877f7bf7a17f44bd17dd1f0bbfd88abdab67ad72.tar.zst Nix-877f7bf7a17f44bd17dd1f0bbfd88abdab67ad72.zip |
Hardcode ssh keys for normal login
Diffstat (limited to 'flakes/private/ssh')
-rwxr-xr-x | flakes/private/ssh/ldap_authorized_keys.sh | 34 |
1 files changed, 0 insertions, 34 deletions
diff --git a/flakes/private/ssh/ldap_authorized_keys.sh b/flakes/private/ssh/ldap_authorized_keys.sh index f4395be..38fa750 100755 --- a/flakes/private/ssh/ldap_authorized_keys.sh +++ b/flakes/private/ssh/ldap_authorized_keys.sh | |||
@@ -1,7 +1,6 @@ | |||
1 | #!/usr/bin/env bash | 1 | #!/usr/bin/env bash |
2 | 2 | ||
3 | LDAPSEARCH=ldapsearch | 3 | LDAPSEARCH=ldapsearch |
4 | KEY="immaeSshKey" | ||
5 | LDAP_BIND="cn=ssh,ou=services,dc=immae,dc=eu" | 4 | LDAP_BIND="cn=ssh,ou=services,dc=immae,dc=eu" |
6 | LDAP_PASS=$(cat /etc/ssh/ldap_password) | 5 | LDAP_PASS=$(cat /etc/ssh/ldap_password) |
7 | LDAP_HOST="ldap://ldap.immae.eu" | 6 | LDAP_HOST="ldap://ldap.immae.eu" |
@@ -13,39 +12,6 @@ PSQL_HOST="localhost" | |||
13 | PSQL_USER="immae_auth_read" | 12 | PSQL_USER="immae_auth_read" |
14 | PSQL_PASS=$(cat /etc/ssh/psql_password) | 13 | PSQL_PASS=$(cat /etc/ssh/psql_password) |
15 | 14 | ||
16 | suitable_for() { | ||
17 | type_for="$1" | ||
18 | key="$2" | ||
19 | |||
20 | if [[ $key != *$'\n'* ]] && [[ $key == ssh-* ]]; then | ||
21 | echo "$key" | ||
22 | else | ||
23 | key_type=$(cut -d " " -f 1 <<< "$key") | ||
24 | |||
25 | if grep -q "\b-$type_for\b" <<< "$key_type"; then | ||
26 | echo "" | ||
27 | elif grep -q "\b$type_for\b" <<< "$key_type"; then | ||
28 | echo $(sed -e "s/^[^ ]* //g" <<< "$key") | ||
29 | else | ||
30 | echo "" | ||
31 | fi | ||
32 | fi | ||
33 | } | ||
34 | |||
35 | clean_key_line() { | ||
36 | type_for="$1" | ||
37 | line="$2" | ||
38 | |||
39 | if [[ "$line" == $KEY::* ]]; then | ||
40 | # base64 keys should't happen, unless wrong copy-pasting | ||
41 | key="" | ||
42 | else | ||
43 | key=$(sed -e "s/^$KEY: *//" -e "s/ *$//" <<< "$line") | ||
44 | fi | ||
45 | |||
46 | suitable_for "$type_for" "$key" | ||
47 | } | ||
48 | |||
49 | ldap_search() { | 15 | ldap_search() { |
50 | $LDAPSEARCH -H $LDAP_HOST -ZZ -b $LDAP_BASE -D $LDAP_BIND -w "$LDAP_PASS" -x -o ldif-wrap=no -LLL "$@" | 16 | $LDAPSEARCH -H $LDAP_HOST -ZZ -b $LDAP_BASE -D $LDAP_BIND -w "$LDAP_PASS" -x -o ldif-wrap=no -LLL "$@" |
51 | } | 17 | } |