Home Cloud Connecting to your Amazon EC2 Instance using SSH

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

Once you have launched your instance, it takes few minutes for the instance to be active so that one can connect to it. Once it’s active check that if it has passed its status-checks which can be viewed on the Instance page in the Status Checks column. If you get any problem connecting to your instance, do comment below to get rid of your doubt or problem otherwise you can go to the docs of the Amazon Web Services for Troubleshooting Connecting your Instance.

In this post you will learn connecting to your instance via Command Line Interface (CLI) because of some of the users are more suitable working with CLI rather than going with GUI. So, follow the procedure below to connect to your EC2 instance using SSH client:

Connecting to your instance using SSH

  • Open the Terminal application. You can additionally use the crosscut Ctrl+Alt+T
  • Install the Amazon EC2 Command Line Interface tools : If you have got already installed it then its okay otherwise use the subsequent command
sudo apt-get install awscli
  • Use the chmod command to form your private key pair file secure from being viewed by some another user.
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 ssh command by specifying the path to your private key (.pem) file and user_name@public_dns_name. The user name for Amazon Linux is either root or ec2-user. The user name for Ubuntu is ubuntu. Otherwise, check with your AMI provider if either of the user name don’t work.
ssh -i /path/your_key_name.pem ubuntu@ec2-52-36-48-168.us-west-2.compute.amazonaws.com


  • Type 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

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.


  • Now to configure, you would like to enter the subsequent command on your Terminal application provided you ought to be connected to your instance
 aws configure
  • Then it’ll be asking you for the configuration variables that you have got downloaded simply on top of. Enter those variables to configure


  • 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





Please enter your comment!
Please enter your name here

5 × one =