From 3ab8c96270a6aa5e3b0d661ffb77b8e7a991dfbf Mon Sep 17 00:00:00 2001 From: Daniel Dolezal Date: Fri, 1 Jul 2022 18:23:54 +0200 Subject: [PATCH] fix bug of only one ssh key can be added --- README.md | 2 +- entrypoint.sh | 10 ++++++++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0aca85c..140419d 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ docker run -dp 3000:22 \ ## Use after setup ``` -export BORG_REPO='ssh://borg@localhost:3000/backups' +export BORG_REPO='ssh://borg@localhost:3000/backups' borg init -e none # any borg command you like ``` diff --git a/entrypoint.sh b/entrypoint.sh index 34c4be8..186db29 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -37,7 +37,13 @@ function add_borg_user { function make_and_import_ssh_keys { local create_folders="0" - touch "/.ssh/authorized_keys" + + if [ ! -f "/.ssh/authorized_keys" ]; then + touch "/.ssh/authorized_keys" + else + rm "/.ssh/authorized_keys" + touch "/.ssh/authorized_keys" + fi for key in ${SSH_FOLDERS[@]}; do if [ ! -d "${key}" ]; then @@ -59,7 +65,7 @@ function make_and_import_ssh_keys { FILES=$(ls -1 /sshkeys/clients) for key in $FILES; do echo "- Adding SSH-Key $key" - cat "/sshkeys/clients/$key" > "/.ssh/authorized_keys" + cat "/sshkeys/clients/$key" >> "/.ssh/authorized_keys" done echo "" >> "/.ssh/authorized_keys"