Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 [email protected]

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?

like image 551
gerdemb Avatar asked Dec 02 '25 03:12

gerdemb


1 Answers

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.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!