From edff8dc5d0fb7c88942c451a1b1e6d1b426f6a0e Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 9 Feb 2015 17:32:57 +0100 Subject: [ssh-auth-keys] static module to copy keys from /root/.ssh/authorized_keys.d/ into /root/.ssh/authorized_keys --- .../systemd/system/basic.target.wants/ssh-auth-keys | 1 + .../data/etc/systemd/system/ssh-auth-keys | 9 +++++++++ .../data/opt/openslx/scripts/systemd-ssh_auth_keys | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+) create mode 120000 remote/modules/ssh-auth-keys/data/etc/systemd/system/basic.target.wants/ssh-auth-keys create mode 100644 remote/modules/ssh-auth-keys/data/etc/systemd/system/ssh-auth-keys create mode 100755 remote/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys (limited to 'remote/modules/ssh-auth-keys/data') 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 -- cgit v1.2.3-55-g7522