Bypass SSH Host ID Check

I’ve been working with AWS for a while and whenever I try to SSH into a new ec2 instance with an already used elastic IP which I re-assign to it I get this annoying message warning me stopping me from SSH’ing.

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @\
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\

To overcome this I could remove the the old host entry from ~/.ssh/known_hosts but often I don’t want to go that trouble before I finish testing the instance properly.

I’ve found a neat little command which helps me get around this by using the -o option flag to tell SSH not to use the knows_hosts file.

ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no remote_username@remote_host

Checkout Ubuntu’s SSH help page for more useful information.