in

How to connect to your EC2 instance?

An EC2 instance is a virtual server in AWS Cloud or you can say instance is like a mini-computer that has its storage, compute capacity, RAM, and network. You can choose an operating system for your instance and all other requirements. In this tutorial, we will see how you can connect to your EC2 instance from your local machine. 

The article is divided into two parts – if you are using a macOS/Linux operating system or if you are using a Windows operating system. So let’s get started with it. 

 

How to connect your EC2 instance with your local computer if you are using Windows Operating  System? 

So to connect our EC2 instance with our local machine we will use a software name Putty. You can download and install PuTTY from here.

 

Prerequisites of connecting to your instance with PuTTY:

  1. Verify that the instance is in a running state.
  2. You have a public DNS or IP address of your instance.
  3. You have successfully downloaded and installed PuTTY on your system.
  4. Convert your private key(.pem) into a .ppk format by using PuTTYgen.

 

How to convert the private key(.pem) into .ppk format?

 

PuTTY doesn’t accept the original private key in .pem format. So we need to convert it into .ppk format which is done by PuTTYgen. 

 

  1. Download the PuTTYgen from here.
  2. Start the program and for the “type of key to generate” option, choose RSA. If your version of PuTTYgen does not include this option, choose SSH-2 RSA.

  1. Choose Load. By default, PuTTYgen will display files only with extension .ppk. So to choose your .pem file, select the option to display all the files. And then select your .pem file. 

  1. After converting the format, make sure you save the new private key file. 

 

Now how to connect with your instance using PuTTY. 

 

  1. Start PuTTY and in the category panel, choose the session option and fill in the following details.

 

  • (Public DNS) To connect using your instance’s public DNS name, enter 

my-instance-user-name@my-instance-public-dns-name

  • (IPv6) If your instance has an IPv6 address, then enter 

my-instance-user-name@my-instance-IPv6-address

 

  1. Ensure the port value is 22 and then from the left panel under Connection expand SSH and then select Auth. Here select the .ppk file you just saved and choose Open.

 

  1. As this is the first time, you are connecting your instance with PuTTY, you may see a warning box. Just agree to that and you will have your instance open on your local system. 

 

How to connect your EC2 instance with your local computer if you are using a Linux or macOS operating system?

Before we start the process, you must check if you have all the prerequisites:

  1. Instance status is running
  2. You have a public DNS or IP address of your instance
  3. An SSH client is installed on your local computer. If you have not already installed it then for Linux and macOS you can download it from here

.

If you have any doubts regarding prerequisites then visit here. Now let’s connect our instance to our local computer. 

 

Open your terminal window and type the following command.

            

ssh -i /path/my-key-pair.pem my-instance-user-name@my-instance-public-dns-name

 

Here in this command, you need to specify the path with the filename of your private key(.pem) which you download during the instance creation. Also, you provide the the user name for your instance, and the IPv6 address or public DNS name for your instance.

 

And if your instance has an IPv6 address then use the following command. 

 

ssh -i /path/my-key-pair.pem my-instance-user-name@my-instance-IPv6-address

 

You will see a response like this:

 

The authenticity of host ‘ec2-198-51-100-1.compute-1.amazonaws.com (198-51-100-1)’ can’t be established.

ECDSA key fingerprint is l4UB/neBad9tvkgJf1QZWxheQmR59WgrgzEimCG6kZY.

Are you sure you want to continue connecting (yes/no)?

 

Enter ‘Yes’!

 

Then you will see a response like this: 

 

Warning: Permanently added ‘ec2-198-51-100-1.compute-1.amazonaws.com’ (ECDSA) to the list of known hosts.

 

Now you have learned how to connect your EC2 instance with your local computer. 

What do you think?

-1 Points
Upvote Downvote

Written by DANN N

Comments

Leave a Reply

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

Loading…

0