From e93381f3a6b96b1ef615e7adad6cf949000228a6 Mon Sep 17 00:00:00 2001 From: Anatoly Kopyl Date: Sat, 3 Apr 2021 16:19:23 +0300 Subject: [PATCH] Fixed the prompt --- sshukh.plugin.zsh | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/sshukh.plugin.zsh b/sshukh.plugin.zsh index a705415..78e99ff 100755 --- a/sshukh.plugin.zsh +++ b/sshukh.plugin.zsh @@ -1,12 +1,27 @@ +# ------------------------------------------------------------------------------ +# Description +# ----------- +# +# User will be prompted if they want to update known_hosts if ssh errors out +# with "Host key verification failed." +# +# ------------------------------------------------------------------------------ +# Authors +# ------- +# +# * Anatoly +# +# ------------------------------------------------------------------------------ + sshukh () { - output=$(ssh "$@") + output=$(\ssh "$@") if [ $? -eq 255 ]; then host=$(cut -d'@' -f2 <<< $1) while true; do - read -p "Update known_hosts? [y/n] " yn + read yn"?Update known_hosts? [y/n] " case $yn in - [Yy]* ) ssh-keygen -R $host && ssh "$@"; break;; + [Yy]* ) ssh-keygen -R $host && \ssh "$@"; break;; [Nn]* ) exit;; * ) echo "Please answer y or n.";; esac