Connecting to your Amazon EC2 Instance using SSH

Assuming that you have Launched an Instance,  and Downloaded the Key Pair file i.e. your .pem file before connecting to it.

If you have not launched then you can do it by following this link – LAUNCHING AN INSTANCE

Connecting to your instance using SSH

  • Open the Terminal application. You can also use the shortcut Ctrl+Alt+T
  • Install the Amazon EC2 CLI tools : If you have already installed it then its okay otherwise use the following command
sudo apt-get install awscli
  • Use the chmod command to make sure that your private key pair file isn’t publicly viewable.
chmod 400 /path/your_key_name.pem

where path is the directory in which your private key file i.e. PEM file is located.

  •  Use the ssh command to connect to the instance. You’ll specify the private key (.pem) file and user_name@public_dns_name. For Amazon Linux, the user name is ec2-user. The user name is either root or ec2-user. For Ubuntu, the user name is ubuntu. Otherwise, if ec2-user and root don’t work, check with your AMI provider.
ssh -i /path/your_key_name.pem


  • Enter yes

Now, you are connected to your instance and all you need to configure your instance which will install apache on your instance.

To Configure your Instance using Terminal

  • You will need to get the Access Keys i.e. your Access Key ID and Secret Access Key. If you don’t have it then you can get that by going to your Security Credentials

Screenshot from 2016-02-12 13-40-01

You will be redirected to the following page where it will ask to Create a New Access Key. Create a new Key and Download it.

Screenshot from 2016-02-12 13-48-14

  • Now to configure, you need to enter the following command on your Terminal application provided you should be connected to your instance
 aws configure
  • Then it will be asking you for the configuration variables which you have downloaded just above. Enter those variables to configure

Screenshot from 2016-02-12 16-58-36

  • You have now successfully configured your instance now you just need to install the lamp-server on your instance by writing the following command on your terminal while connected to the instance
sudo apt-get install lamp-server^
  • Then, it will ask for a new password enter it and you are done. Now just copy your instance’s Public DNS Name and paste in a new tab of your browser and you will see this apache page


5 thoughts on “Connecting to your Amazon EC2 Instance using SSH

Leave a Reply

Your email address will not be published. Required fields are marked *

one × two =