Sanjok Gurung Sanjok Gurung - 13 days ago 4x
Linux Question

Login to Amazon EC2 via ssh

I have a question and am stuck at something. I recently created AWS EC2 Ubuntu instance with default settings. I have an Ubuntu machine locally as well and so far I managed to connect successfully to the Ubuntu instace with this command

ssh -i /var/www/my-key-pair.pem

However I want to know if there is a simpler way to login to ssh without passing the private key everytime I login and add its ip to my
so that I could login as easily as
ssh ubuntu@some.ip.number
. By the way I am using AWS free tier package.


Create ~/.ssh/config with:

Host myhost
  IdentityFile /var/www/my-key-pair.pem
  Use ec2-user

And the you can login using ssh myhost.