]> git.immae.eu Git - perso/Immae/Config/Nix.git/blame - flakes/private/ssh/ldap_authorized_keys.sh
Hardcode ssh keys for normal login
[perso/Immae/Config/Nix.git] / flakes / private / ssh / ldap_authorized_keys.sh
CommitLineData
5566d26d
IB
1#!/usr/bin/env bash
2
3LDAPSEARCH=ldapsearch
5566d26d 4LDAP_BIND="cn=ssh,ou=services,dc=immae,dc=eu"
ea7bf00c 5LDAP_PASS=$(cat /etc/ssh/ldap_password)
1a64deeb 6LDAP_HOST="ldap://ldap.immae.eu"
5566d26d 7LDAP_BASE="dc=immae,dc=eu"
1a64deeb
IB
8USER_LDAP_BASE="ou=users,dc=immae,dc=eu"
9
10PSQL_BASE="immae"
11PSQL_HOST="localhost"
12PSQL_USER="immae_auth_read"
13PSQL_PASS=$(cat /etc/ssh/psql_password)
5566d26d 14
5566d26d 15ldap_search() {
1a64deeb
IB
16 $LDAPSEARCH -H $LDAP_HOST -ZZ -b $LDAP_BASE -D $LDAP_BIND -w "$LDAP_PASS" -x -o ldif-wrap=no -LLL "$@"
17}
18
19psql_search() {
20 PGPASSWORD="$PSQL_PASS" psql -U "$PSQL_USER" -h "$PSQL_HOST" -X -A -t -d "$PSQL_BASE" -c "$@"
5566d26d
IB
21}
22
23ldap_keys() {
24 user=$1;
1b9150a5 25 @snippets@
5566d26d
IB
26}
27
28ldap_keys $@