AUTH="$NBT_HOME/.ssh/authorized_keys"
sudo_() { sudo -u novaboot-test "$@"; }
-WVSTART "Check that ssh-agent needed for following tests is running"
+WVSTART "Create and check ssh keys needed for following tests"
+# Start our custom ssh-agent to not mess up with the user's agent
+eval "$(ssh-agent)"
+trap 'ssh-agent -k' EXIT
WVPASS test -n "$SSH_AUTH_SOCK" || exit 1
+if [ ! -f id_rsa ]; then
+ ssh-keygen -t rsa -C "generated by $0" -N '' -f ./id_rsa
+fi
+WVPASS ssh-add ./id_rsa
WVSTART "Setup SSH server's admin key"
-WVPASS ssh-add -L > keys
-WVPASS test $(wc -l < keys) -gt 0
WVPASS sudo_ mkdir -p $(dirname "$AUTH")
WVPASS sudo_ chmod 700 $(dirname "$AUTH")
-WVPASS sudo_ tee "$AUTH" <<<"command=\"user test admin\" $(tail -n 1 keys)"
+WVPASS sudo_ tee "$AUTH" <<<"command=\"user test admin\" $(cat ./id_rsa.pub)"
+exit
WVSTART "Novaboot --ssh option (connect, rsync, reset)"
WVPASS sudo_ rm -rf "$TFTPROOT"