Created
May 16, 2015 00:50
-
-
Save craSH/b3d27b811e8ff2c203b0 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
function ssh-keygen-remove-all() { | |
if [ -n $1 ]; then | |
ssh-keygen -R "$1" >/dev/null 2>&1 && \ | |
echo "Removed complete hostname: $1" | |
simple_host=$(echo $1 | cut -d '.' -f1) | |
if [ -n "$simple_host" ]; then | |
ssh-keygen -R "$simple_host" >/dev/null 2>&1 && \ | |
echo "Removed short hostname: $simple_host" | |
fi | |
host_ip=$(dig +short "$1") | |
if [ -n "$host_ip" ]; then | |
for ip in "$host_ip"; do | |
ssh-keygen -R "$host_ip" >/dev/null 2>&1 && \ | |
echo "Removed resolved hostname: $host_ip" | |
done | |
fi | |
fi | |
} | |
ssh-keygen-remove-all |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment