How to SSH into EC2 instances without identity file and password?

I had to type in the location and name of my identity file and a long string of username@hostname anytime I'd try to SSH into my Amazon EC2 instance for administration. I found an easy solution that I am sharing with you here.

Run the following command from MacOS X's command line to see if you already have a config file.

ls -lah ~/.ssh/config

If the file and/or directory does not exist then you have to create both and type in the following in ~/.ssh/config file.

Host geeksww.com
   HostName ec2-11-11-111-111.compute-1.amazonaws.com
   User ubuntu
   IdentityFile /Users/geeksww.com/secure/identity.pem

Save the file and exit out of the editor. Now, you can run the following command to SSH into ec2-11-11-111-111.compute-1.amazonaws.com using geeksww as the username.

ssh geeksww.com

Details:

The first line uses a shortcut name that you'd use to connect to the SSH host you want to connect to. In my case, I used geeksww.com.

Hostname indicates the hostname of the destination SSH server that you want to connect to.

User defines the user name that you need to connect to the SSH server.

IdentityFile indicates the complete path to the identity file that you need to connect to the SSH host.

Did this tutorial help a little? How about buy me a cup of coffee?

Buy me a coffee at ko-fi.com

Please feel free to use the comments form below if you have any questions or need more explanation on anything. I do not guarantee a response.

IMPORTANT: You must thoroughy test any instructions on a production-like test environment first before trying anything on production systems. And, make sure it is tested for security, privacy, and safety. See our terms here.