diff options
Diffstat (limited to 'remote/modules/ssh-auth-keys/data')
3 files changed, 31 insertions, 0 deletions
diff --git a/remote/modules/ssh-auth-keys/data/etc/systemd/system/basic.target.wants/ssh-auth-keys b/remote/modules/ssh-auth-keys/data/etc/systemd/system/basic.target.wants/ssh-auth-keys new file mode 120000 index 00000000..ea20ff73 --- /dev/null +++ b/remote/modules/ssh-auth-keys/data/etc/systemd/system/basic.target.wants/ssh-auth-keys @@ -0,0 +1 @@ +../ssh-auth-keys
\ No newline at end of file diff --git a/remote/modules/ssh-auth-keys/data/etc/systemd/system/ssh-auth-keys b/remote/modules/ssh-auth-keys/data/etc/systemd/system/ssh-auth-keys new file mode 100644 index 00000000..14b12bc5 --- /dev/null +++ b/remote/modules/ssh-auth-keys/data/etc/systemd/system/ssh-auth-keys @@ -0,0 +1,9 @@ +[Unit] +Description=Enable SSH keys in authorized_keys.d/ folder +Wants=basic.target +Before=basic.target + +[Service] +Type=oneshot +RemainAfterExit=yes +ExecStart=/opt/openslx/scripts/systemd-ssh_auth_keys diff --git a/remote/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys b/remote/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys new file mode 100755 index 00000000..b3c7a6fe --- /dev/null +++ b/remote/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys @@ -0,0 +1,21 @@ +#!/bin/ash + +AUTH_KEYS_DIR="/root/.ssh/authorized_keys.d/" +AUTH_KEYS_FILE="/root/.ssh/authorized_keys" + +# root-check +[ "$(id -u)" -ne 0 ] && echo "Need to be root. Exiting." && exit 1 + +# do we even have the directory? +[ ! -d "$AUTH_KEYS_DIR" ] && echo "No such directory: $AUTH_KEYS_DIR" && exit 1 + +# ok, lets cat them in the real file +for KEY in "$AUTH_KEYS_DIR"/* ; do + if ! cat $KEY >> "$AUTH_KEYS_FILE" ; then + echo "Could not add '$KEY' to '$AUTH_KEYS_FILE'" + exit 1 + fi +done + +# all done, all good +exit 0 |
