I start/stop lots of new instances as I'm learning to use Amazon EC2. Every temporary instance is added to the known_hosts file. Is this ever a problem for others who use EC2 a lot?

I'd like to tell ssh to skip this step anytime I connect to amazonaws.com. Is there a way to do that in the config? I'm using Linux & openssh.

link|improve this question
feedback

2 Answers

up vote 1 down vote accepted

This is done to prevent Man in the Middle attacks. Disabling it would disable basic functionality of the ssh tools.

You may want to keep a copy of your .ssh/known_hosts file without the entries and replace it when you are done.

link|improve this answer
You can create a simple bash function for these such as ecssh () { ssh $1; cp .ssh/saved_hosts .ssh/known_hosts } <-- That syntax isn't exact, but it shows the idea. – Doug Harris Jan 25 '11 at 15:30
Thanks. I believe for EC2 you're supposed to check the fingerprint with the instance's system log. – projectshave Jan 25 '11 at 21:39
Found the issue with my syntax. Needs a semicolon after the cp command: ecssh () { ssh $1; cp .ssh/saved_hosts .ssh/known_hosts; } – Doug Harris Jan 26 '11 at 16:28
feedback

Try this:

ssh -q -oUserKnownHostsFile=/dev/null -oStrictHostKeyChecking=no -i $MYKEY $MYUSERNAME@$MYIP $MYCOMMAND

You can also do this in your config file:

Host *.amazonaws.com
  User root
  StrictHostKeyChecking no
  UserKnownHostsFile /dev/null
  LogLevel QUIET
link|improve this answer
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.