I often create and destroy a virtual machine multiple times in development. SSH records the host and key and often complains about a changed value for a given key. As I am attempting to automate more and more, I need to be able to communicate with these recreated hosts without dealing with the warning messages.
#!/bin/sh if test "$#" -lt 1 then echo "usage $0
" echo echo "Will remove the ipaddress from the known hosts file," echo "and then make an ssh call to the host without strict," echo "host checking to repopulate it. This is risky if you" echo "do not know for certain that you are talking to the" echo "correct host." exit 1 fi IPADDR=$1 if test "$#" -eq 2 then USERNAME=$2 else USERNAME=centos fi sed -i.bak '/^$IPADDR/d' ~/.ssh/known_hosts ssh -o "StrictHostKeyChecking=no" $USERNAME@$IPADDR hostname