summaryrefslogtreecommitdiff
path: root/remove-known-host.sh
diff options
context:
space:
mode:
Diffstat (limited to 'remove-known-host.sh')
-rwxr-xr-xremove-known-host.sh13
1 files changed, 10 insertions, 3 deletions
diff --git a/remove-known-host.sh b/remove-known-host.sh
index d2c8b8d5..04ead3e5 100755
--- a/remove-known-host.sh
+++ b/remove-known-host.sh
@@ -5,10 +5,17 @@ if [ -z "$1" ]; then
exit 1
fi
-SHORT="$1"
-SSH_HOST=$(ssh -G "$1" | grep "^hostname " | awk '{ print($2) }' )
+short="$1"
+ssh_host=$(ssh -G "$short" | grep "^hostname " | awk '{ print($2) }' )
+ssh_port=$(ssh -G "$short" | grep "^port " | awk '{ print($2) }' )
-for name in $SHORT $SSH_HOST; do
+cd "${BASH_SOURCE%/*}"
+source common/utils.sh
+ansible_variable__get host_name "$short" || exit 1
+ansible_variable__get host_domain "$short" || exit 1
+
+
+for name in "$short" "$ssh_host" "$ssh_host:$ssh_port" "[$ssh_host]:$ssh_port" "$host_name" "$host_name.$host_domain"; do
ssh-keygen -f "$HOME/.ssh/known_hosts" -R "$name"
done