Automate SSH in Linux to EC2 Image

To automate the process of SSH'ing into an EC2 image so you don't have to reference the keys everytime, you must edit the config files for OpenSSH. OpenSSH looks at the config files and reads the first value given and ignores any overwrites later. /[username]/.ssh/config is the user specfic config file that has to be configured

 and /etc/ssh/ssh_config is the general config file.

Place the following in the config file:
HOST *.amazonaws.com
IdentityFile location_of_pem_key_file_from_ec2
User root

Then run:
chmod 600 [location of pem key file from ec2]

Now to SSH to an EC2 image all you have to do is run:
ssh ec2-75-101-239-13.compute-1.amazonaws.com

0 comments:

Post a Comment