summaryrefslogtreecommitdiff
path: root/remove-known-host.sh
diff options
context:
space:
mode:
Diffstat (limited to 'remove-known-host.sh')
-rwxr-xr-xremove-known-host.sh29
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