diff options
author | Christian Pointner <equinox@spreadspace.org> | 2017-11-21 22:28:39 +0100 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2017-11-21 22:28:39 +0100 |
commit | 91cd5480b5a1ca1103d5e239af3d331477c41c2c (patch) | |
tree | b495bf31e2d5da50b045838a1e8d0455db09ee65 /remove-known-host.sh |
initial commit as copy from helsinki ansible repo
Diffstat (limited to 'remove-known-host.sh')
-rwxr-xr-x | remove-known-host.sh | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/remove-known-host.sh b/remove-known-host.sh new file mode 100755 index 00000000..9aecb8e7 --- /dev/null +++ b/remove-known-host.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +if [ -z "$1" ]; then + echo "$0 <host>" + exit 1 +fi + +TMP=`host -t A "$1" | grep -v "has no"` +IP=`echo "$TMP" | awk '{ print($4) }'` +HOST=`echo "$TMP" | awk '{ print($1) }'` + +TMP=`host -t AAAA "$1" | grep -v "has no"` +IP6=`echo "$TMP" | awk '{ print($5) }'` +HOST6=`echo "$TMP" | awk '{ print($1) }'` + +if [ "$HOST6" = "$HOST" ]; then + HOST6="" +fi +SHORT="$1" +if [ "$SHORT" = "$HOST" ] || [ "$SHORT" == "$HOST6" ]; then + SHORT="" +fi + + +for name in $IP $IP6 $HOST $HOST6 $SHORT; do + ssh-keygen -f "/home/rhadmin/.ssh/known_hosts" -R "$name" +done + +exit 0 |