Only use publickey authentification
authorAlexander Barton <alex@barton.de>
Tue, 20 Dec 2016 21:07:05 +0000 (22:07 +0100)
committerAlexander Barton <alex@barton.de>
Tue, 20 Dec 2016 21:07:05 +0000 (22:07 +0100)
scripts/trigger-rcmd

index 75aeddb..90c19bd 100755 (executable)
@@ -74,12 +74,14 @@ do_rcmd() {
        fi
 
        for i in $(seq 1 $SSH_CHECKS); do
-               echo "$NAME: Checking SSH connection ($i/$SSH_CHECKS) ..."
-               ssh -q "$SYSTEM" true >/dev/null 2>&1 && break
+               echo "$NAME: Checking SSH connection [publickey] ($i/$SSH_CHECKS) ..."
+               if ssh -o PreferredAuthentications=publickey -q "$SYSTEM" true >/dev/null 2>&1; then
+                       echo "$NAME: Ok, SSH seems to be available on \"$SYSTEM\"."
+                       break
+               fi
                echo "$NAME: SSH on \"$SYSTEM\" not ready. Waiting ..."
                sleep 10s
        done
-       echo "$NAME: Ok, SSH seems to be available on \"$SYSTEM\"."
 
        if [ "$rsys_was_running" -eq 0 ]; then
                echo "$NAME: \"$SYSTEM\" just started up. Delaying actions for $BOOT_DELAY ..."
@@ -90,7 +92,7 @@ do_rcmd() {
        echo
 
        # shellcheck disable=2029
-       ssh -q "$SYSTEM" "$CMD" </dev/null ; r=$?
+       ssh -o PreferredAuthentications=publickey -q "$SYSTEM" "$CMD" </dev/null ; r=$?
 
        echo
        echo "$NAME: Remote command ended with return code $r."
@@ -101,7 +103,7 @@ do_rcmd() {
                if [ "$rsys_users" = "0" ]; then
                        echo "$NAME: Power off \"$SYSTEM\" again ..."
                        # shellcheck disable=2029
-                       ssh -q "$SYSTEM" "sync; shutdown -hP $SHUTDOWN_TIME" >/dev/null
+                       ssh -o PreferredAuthentications=publickey -q "$SYSTEM" "sync; shutdown -hP $SHUTDOWN_TIME" >/dev/null
                        if [ $? -ne 0 ]; then
                                echo "$NAME: Failed to power off \"$SYSTEM\"!" >&2
                                return 5