Made the script trigger only on key verification fail

This commit is contained in:
2021-04-03 19:20:08 +03:00
parent 06017a74b9
commit 91db04d424

View File

@@ -14,9 +14,10 @@
# ------------------------------------------------------------------------------ # ------------------------------------------------------------------------------
sshukh () { sshukh () {
output=$(\ssh "$@") output=$(\ssh "$@" 2>&1)
if [ $? -eq 255 ]; echo $output
then error=$(echo $output | tail -1)
if [[ "$error" == "Host key verification failed."* ]]; then
host=$(cut -d'@' -f2 <<< $1) host=$(cut -d'@' -f2 <<< $1)
while true; do while true; do
read yn"?Update known_hosts? [y/n] " read yn"?Update known_hosts? [y/n] "