2013-11-19 17:32:05 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
2024-06-28 12:28:56 +02:00
|
|
|
function ssh_clean_known_hosts() {
|
|
|
|
if [ -z "$1" ]; then
|
2013-11-19 17:32:05 +01:00
|
|
|
echo "No arguments given. Cleaning ~/.ssh/known_hosts"
|
|
|
|
sed -i -e '/no hostip for proxy command/ d' ~/.ssh/known_hosts
|
|
|
|
else
|
|
|
|
hostname=$1
|
2024-06-28 12:28:56 +02:00
|
|
|
ip=$(ssh admin dig +short "$1")
|
2013-11-19 17:32:05 +01:00
|
|
|
echo "Removing host ${hostname} from ~/.ssh/known_hosts"
|
|
|
|
sed -i -e "/${hostname}/ d" ~/.ssh/known_hosts
|
|
|
|
echo "Removing ip ${ip} from ~/.ssh/known_hosts"
|
|
|
|
sed -i -e "/${ip}/ d" ~/.ssh/known_hosts
|
|
|
|
fi
|
|
|
|
|
|
|
|
}
|