fix bug of only one ssh key can be added

This commit is contained in:
2022-07-01 18:23:54 +02:00
parent cb3137a55c
commit 3ab8c96270
2 changed files with 9 additions and 3 deletions
+1 -1
View File
@@ -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
```
+8 -2
View File
@@ -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"