diff --git a/libs/ssh.bash b/libs/ssh.bash new file mode 100644 index 0000000..13ad104 --- /dev/null +++ b/libs/ssh.bash @@ -0,0 +1,18 @@ +#!/bin/bash + +function ssh_clean_known_hosts () +{ + if [ -z "$1" ] + then + echo "No arguments given. Cleaning ~/.ssh/known_hosts" + sed -i -e '/no hostip for proxy command/ d' ~/.ssh/known_hosts + else + hostname=$1 + ip=$(ssh admin dig +short $1) + 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 + +}