-->

Monday, March 17, 2014

Accessing an EC2 instance on Amazon

To access an EC2 linux machine in EC2 it is very easy. But you need to have some basic access information regarding the machine. In particular you need:
  • the ip address of the machine : 243.235.82.10
  • a private key file : mykey.pem
  • a name through which you want to identify the machine in the future: mysupermachine

First of all copy your key file into ~/.ssh/

cp ~/mykey.pem  ~/.ssh/

Enhance protection of your key by setting the correct rights to the file:
chmod 400 ~/.ssh/mykey.pem

Modify (or create) the file ~/.ssh/config and add the following lines
Host mysupermachine
User ubuntu
Hostname 243.235.82.10
IdentityFile ~/.ssh/mykey.pem

 
Host *
ForwardX11 yes
ForwardAgent yes
ServerAliveInterval 5

Note that in the Ubuntu 13.10 AMI the default user is ubuntu but in other AMIs like centos the user that you have to use is root.

Now every time you want to connect to the machine you just need to type in your console


ssh mysupermachine

No comments:

Post a Comment