Created
March 7, 2015 07:43
-
-
Save mindware/260c38312b931739191b to your computer and use it in GitHub Desktop.
Bash script to clear old SSH hosts from known_hosts and rescan them
This file contains 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
# say you save this as clear.sh | |
# chmod +x clear.sh | |
# usage: ./clear.sh <host1> <host2> <host..n> | |
for var in "$@" | |
do | |
echo "Clearing $var from host file." | |
ssh-keygen -f "$HOME/.ssh/known_hosts" -R $var | |
echo "Key scanning $var" | |
ssh-keyscan $var >> ~/.ssh/known_hosts | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment