Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

How to connect Linux EC2 Instance from Windows and Linux

Here, we will learn how to connect to AWS EC2 instance from your local machine (Windows/Ubuntu) .

Prerequisite

1. Considering that you have successfully created a AWS Account.


2. You have also created a AWS EC2 Instance on your AWS Account.
3. Get Ready with your private key file (.pem). That your have generated while creating EC2 instance .

Steps to Connect EC2 From Windows

1. Download and Install Putty on your local machine

Download and install PuTTY from the PuTTY download page. If you already have an older version of PuTTY installed please Update it , Be sure
to install the entire suite.

2. Convert your private key using PuTTYgen

PuTTY does not natively support the private key format for SSH keys. PuTTY provides a tool named PuTTYgen, which converts keys to the
required format for PuTTY. You must convert your private key (.pem file) into this format (.ppk file) as follows in order to connect to your instance
using PuTTY.

1. From the Start menu, choose All Programs then PuTTYgen.

1. Under

Type of key to generate, choose RSA. If you’re using an older version of PuTTYgen, choose SSH-2 RSA.

1. Choose
Load. By default, PuTTYgen displays only files with the extension .ppk . To locate your .pem file, choose the option to display files of all types.

1. Select your

.pem file. It will show a message successfully imported now save your private key .

Your private key is now in the correct format for use with PuTTY. You can now connect to your instance using PuTTY’s SSH client.

3. Connect To EC2 Using Putty

1. Start PuTTY (from the

Start menu, choose All Programs, PuTTY, PuTTY) .

1. In the

Category pane, choose Session and complete the following fields :


Enter Host_name = my-instance-user-name@my-instance-public-dns-name
Enter Port = 22
Connection Type = SSH

“Replace “my-instance-user-name@my-instance-public-dns-name” with your host name and user name . You will find these
details on AWS EC2 Dashboard. Go to EC2 dashboard. Click on your instance. Click on connect you will these find details in
Example there . ”
1. In the

Category pane, expand Connection, expand SSH, and then choose Auth then Browse and Select the .ppk file that you generated for your key
pair and choose open .
1. (Optional) If you plan to start this session again later, you can save the session information for future use. Under

Category, choose Session, enter a name for the session in Saved Sessions, and then choose Save.

1. Choose

Open.

“If this is the first time you have connected to this instance, PuTTY displays a security alert dialog box that asks whether you trust
the host to which you are connecting. Choose yes . ”

“You are now connected to your EC2 Instance from Windows”

Steps to Connect EC2 From Ubuntu


To connect to your EC2 Instance from Ubuntu .

1. Open Terminal .
2. Go to the folder Where your private key is stored .
3. Run the Below Command to connect to your EC2 instance .

$ sudo ssh -i "yourPrivateKey.pem" my-instance-user-name@my-instance-


public-dns-name

Terminal Example

Replace “my-instance-user-name@my-instance-public-dns-name” with your host name and user name . You will find these
details on AWS EC2 Dashboard. Go to EC2 dashboard. Click on your instance. Click on connect you will these find details in
Example there . ”

“If this is the first time you have connected to this instance, It will displays a security alert Choose yes to connect to EC2 instance ”

You might also like