diff options
author | Jonathan Bauer | 2015-02-09 17:32:57 +0100 |
---|---|---|
committer | Jonathan Bauer | 2015-02-09 17:32:57 +0100 |
commit | edff8dc5d0fb7c88942c451a1b1e6d1b426f6a0e (patch) | |
tree | 57306720aa6ed9a5df65806438603df0705f5343 | |
parent | [systemd] force reset on the tty before it is spawned (diff) | |
download | tm-scripts-edff8dc5d0fb7c88942c451a1b1e6d1b426f6a0e.tar.gz tm-scripts-edff8dc5d0fb7c88942c451a1b1e6d1b426f6a0e.tar.xz tm-scripts-edff8dc5d0fb7c88942c451a1b1e6d1b426f6a0e.zip |
[ssh-auth-keys] static module to copy keys from /root/.ssh/authorized_keys.d/ into /root/.ssh/authorized_keys
5 files changed, 45 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 diff --git a/remote/modules/ssh-auth-keys/module.build b/remote/modules/ssh-auth-keys/module.build new file mode 100644 index 00000000..97e93235 --- /dev/null +++ b/remote/modules/ssh-auth-keys/module.build @@ -0,0 +1,11 @@ +fetch_source() { + : +} + +build() { + : +} + +post_copy() { + : +} diff --git a/remote/modules/ssh-auth-keys/module.conf b/remote/modules/ssh-auth-keys/module.conf new file mode 100644 index 00000000..0cd03752 --- /dev/null +++ b/remote/modules/ssh-auth-keys/module.conf @@ -0,0 +1,3 @@ +REQUIRED_BINARIES="" +REQUIRED_LIBRARIES="" +REQUIRED_DIRECTORIES="" |