Skip to content

Instantly share code, notes, and snippets.

@frimik
Created March 30, 2012 13:47
Show Gist options
  • Select an option

  • Save frimik/2251663 to your computer and use it in GitHub Desktop.

Select an option

Save frimik/2251663 to your computer and use it in GitHub Desktop.
ssh-clean: convenience function for cleaning up changed host keys.
# clean known host key of a certain host.
# attempts reverse dns lookup.
# requires dig
if [ -z "$1" ]; then
echo "Usage: ssh-clean hostname"
return
fi
arg=${1#*@}
echo "Cleaning for $arg..."
ssh-keygen -R $arg
reverse=$(dig +short $arg)
if [ -n "$reverse" ]; then
echo "Cleaning for $reverse..."
ssh-keygen -R $reverse
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment