Wednesday, July 3, 2013

My Notes: Configuring SSH to Connect to AWS

To make it easier for me to ssh to my EC2 instance and also to do my git push to my gitrepo on the EC2 instance I create ssh config file which content looks like this:

@mbp ~$ cat ~/.ssh/config
Host smallec2
Hostname ec2-xx-xxx-xxx-xxx.us-west-1.compute.amazonaws.com
User edylou
IdentityFile /Users/elousf/aws/keys/my.pem 


Host miniec2
Hostname ec2-xx-xxx-xx-xx.us-west-1.compute.amazonaws.com
User elousf
IdentityFile /Users/elousf/aws/keys/test.pem 


With that ssh config, instead of doing something like:
$ ssh -i /path/to/my/pem-file elousf@ec2-xx-xx-xxxx-xxx.us-west1.compute.amazonaws.com

I can do
$ ssh elousf@smallec2

Which also simplifies my git remote operations.
Another good effect is since I often turning off my EC2 instance and whenever I need to turn it on I just need to change this ssh config. 

No comments: