Recently I had the need to configure ssh access for some AWS EC2 machines. One annoying element of EC2 machines is that they default to user
ec2-user, which is easy to forget.
Public routable EC2 instances hostnames is in the form of:
ec2-<IP>.compute-1.amazonaws.com. Due to this is easy to create a SSH config file entry to set the default user to
ec2-user for these hostnames:
From this point onward all connections to instances whose hostname ends in
.amazonaws.com will default to the correct value.
What if I have a non-publicly routable instance? Depending on the hostname, you may be able to slightly change the configuration above to suit your needs. If you’re using IP addresses though, you should either do it manually for each host or find a way to automating the manual process.