From 91db04d424aba1d04d5f4cca583d6859bf9d2a59 Mon Sep 17 00:00:00 2001 From: Anatoly Kopyl Date: Sat, 3 Apr 2021 19:20:08 +0300 Subject: [PATCH] Made the script trigger only on key verification fail --- sshukh.plugin.zsh | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sshukh.plugin.zsh b/sshukh.plugin.zsh index 74acbcd..de1d92c 100755 --- a/sshukh.plugin.zsh +++ b/sshukh.plugin.zsh @@ -14,9 +14,10 @@ # ------------------------------------------------------------------------------ sshukh () { - output=$(\ssh "$@") - if [ $? -eq 255 ]; - then + output=$(\ssh "$@" 2>&1) + echo $output + error=$(echo $output | tail -1) + if [[ "$error" == "Host key verification failed."* ]]; then host=$(cut -d'@' -f2 <<< $1) while true; do read yn"?Update known_hosts? [y/n] "