Disabling unidentified host confirmation when connecting to Amazon EC2 instances using SSH

amazon-ec2, amazon-web-services, boto, ssh, ssh-keys

Solution

Use `-O StrictHostKeyChecking=no` and, optionally, set the `KnownHostsFile` of /dev/null (if you want to be totally insecure about things). But remember, you're bypassing security measures meant to protect you!

edit and probably `CheckHostIP=no` too. `man ssh` and see all the gory bits.

Problem

I am writing a script using boto and Python to automatically launch an Amazon EC2 instance and interact with it using SSH. Everything works fine except that every time I establish the connection, SSH prompts me to confirm the authenticity of the host like this: ``` The authenticity of host 'ec2-174-129-121-25.compute-1.amazonaws.com (174.129.121.25)' can't be established. RSA key fingerprint is 26:09:bd:21:4f:55:20:3f:0d:fc:5f:cc:3e:08:30:db. Are you sure you want to continue connecting (yes/no)? ``` My SSH command is: ``` ssh -i ssh2.pem root@ec2-174-129-121-25.compute-1.amazonaws.com ``` Since every EC2 instance is a new host, I have to confirm this every time, but I want an automatic script without any user input. What is the best solution?

Original source