ssh-plugin-test: Copy SSH key manually instead of with ssh-copy-id

ssh-copy-id requires password authentication that might be disabled
on some cloud images. We can simply copy the key manually, because
everything runs on localhost anyway.

Fixes: #701
This commit is contained in:
Vojtech Trefny
2022-02-08 15:11:01 +01:00
parent cef0dc059a
commit 7eb44f32a3

View File

@@ -58,11 +58,11 @@ function bin_check()
function ssh_setup()
{
# .ssh is used by ssh-copy-id for temp files so it must exist even if key is not there
[ -d "$HOME/.ssh" ] || mkdir -m 700 $HOME/.ssh
# copy the ssh key
[ -d "/home/$USER/.ssh" ] || mkdir /home/$USER/.ssh
touch /home/$USER/.ssh/authorized_keys
# ssh-copy-id
sshpass -p $PASSWD ssh-copy-id -i $SSH_KEY_PATH $SSH_OPTIONS $USER@$SSH_SERVER >/dev/null 2>&1
cat $SSH_KEY_PATH.pub >> /home/$USER/.ssh/authorized_keys
[ $? -ne 0 ] && remove_user && skip "Failed to copy SSH key."
# make sure /home/sshtest/.ssh and /home/sshtest/.ssh/authorized_keys have correct permissions