This commit is contained in:
2026-05-25 12:42:22 +02:00
parent 3e8148c75b
commit 2da411bf9f
4 changed files with 19 additions and 5 deletions

View File

@@ -1,7 +1,7 @@
#!/bin/sh
[ -n "$1" ] && login=$1 || read -p "provide login: " login
[ -n "$2" ] && ssh_key=$2 || read -p "provide ssh key: " ssh_key
[ -n "$1" ] && login="$1" || read -p "provide login: " login
[ -n "$2" ] && ssh_key="$(echo $2)" || read -p "provide ssh key: " ssh_key
ssh_dir=/home/$login/.ssh
mkdir -p "$ssh_dir"
@@ -9,7 +9,7 @@ mkdir -p "$ssh_dir"
# add it to authorized_keys but avoid adding it twice
ak=$ssh_dir/authorized_keys
[ ! grep "$ssh_key" $ak ] && echo "$ssh_key" >> $ak
echo "$ssh_key" >> $ak
# ssh wont work without it
chmod -R 0700 /home/$login/.ssh