mirror of
https://github.com/anatolykopyl/sshukh.git
synced 2026-03-26 12:55:02 +00:00
31 lines
775 B
Bash
Executable File
31 lines
775 B
Bash
Executable File
# ------------------------------------------------------------------------------
|
|
# Description
|
|
# -----------
|
|
#
|
|
# User will be prompted if they want to update known_hosts if ssh errors out
|
|
# with "Host key verification failed."
|
|
#
|
|
# ------------------------------------------------------------------------------
|
|
# Authors
|
|
# -------
|
|
#
|
|
# * Anatoly <akopyl@radner.ru>
|
|
#
|
|
# ------------------------------------------------------------------------------
|
|
|
|
sshukh () {
|
|
output=$(\ssh "$@")
|
|
if [ $? -eq 255 ];
|
|
then
|
|
host=$(cut -d'@' -f2 <<< $1)
|
|
while true; do
|
|
read yn"?Update known_hosts? [y/n] "
|
|
case $yn in
|
|
[Yy]* ) ssh-keygen -R $host && \ssh "$@"; break;;
|
|
[Nn]* ) break;;
|
|
* ) echo "Please answer y or n.";;
|
|
esac
|
|
done
|
|
fi
|
|
}
|