Dec 17, 2011

EC2 Friendly SSH Config

If you spend lots of time in EC2 or any other cloud service your going to collect tons of junk in your $HOME/.ssh/known_hosts file. If you're remapping domain names to cloud based servers and those IPs change SSH's default settings will prevent you from connecting until the conflict is fixed. Instead of constantly having to edit known_hosts a better approach is to have SSH ignore known_hosts while you work in the cloud.

Here's my $HOME/.ssh/config. In addition to ignoring known_hosts I also set the identiy key file and the default user.

Host *compute-1.amazonaws.com
User ubuntu
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
IdentityFile ~/.ssh/your-ec2-key
ServerAliveInterval 30
ServerAliveCountMax 120


With these settings I can copy the DNS name straight from the AWS console, type 'ssh ' at the command line, paste the DNS name and then connect; example:

ssh ec2-107-100-123-99.compute-1.amazonaws.com

1 comment:

Unknown said...

Thanks! I just wrote short post explaining ssh config file in bit more details so someone might find it useful.

Do you need ServerAliveInterval. I left my connection over night and didn't got disconnected without those options. What is the default setting?