Created
March 30, 2012 13:47
-
-
Save frimik/2251663 to your computer and use it in GitHub Desktop.
ssh-clean: convenience function for cleaning up changed host keys.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 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