diff options
-rwxr-xr-x | core/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/core/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys b/core/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys index 9a64b83a..d08e78a0 100755 --- a/core/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys +++ b/core/modules/ssh-auth-keys/data/opt/openslx/scripts/systemd-ssh_auth_keys @@ -7,14 +7,18 @@ AUTH_KEYS_FILE="/root/.ssh/authorized_keys" [ ! -d "$AUTH_KEYS_DIR" ] && echo "No such directory: $AUTH_KEYS_DIR" && exit 0 mkdir -m 700 $(dirname "$AUTH_KEYS_FILE") 2>/dev/null +TMP=$(mktemp) + +[ -s "$AUTH_KEYS_FILE" ] && cat "$AUTH_KEYS_FILE" >> "$TMP" # 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 + grep -E '(^#|\bssh-.*\sAAA)' "$KEY" >> "$TMP" done +sort -u "$TMP" > "$AUTH_KEYS_FILE" || cp -f "$TMP" "$AUTH_KEYS_FILE" + +rm -f -- "$TMP" + # all done, all good exit 0 |