Connect to AWS EC2 instance using SSH

Learn how to connect to AWS EC2 instance using SSH

Connect to AWS EC2 instance using SSH

In this tutorial you will learn how to connect to the AWS EC2 instance using a SSH client like Putty.

Prerequisites:

1. AWS EC2 instance is running. (Follow here).

2. Putty is installed in your local machine. (Download Link)

3. 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) in order to connect to your instance using PuTTY.

To convert your EC2 private key follow the below steps:

1. Launch PuTTYgen .

2. Under Type of key to generate, choose RSA.

3. 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.

4. Select your .pem file for the key pair that you specified when you launched your instance and choose Open. PuTTYgen displays a notice that the .pem file was successfully imported. Choose OK.

5. To save the key in the format that PuTTY can use, choose Save private key. PuTTYgen displays a warning about saving the key without a passphrase. Choose Yes.

6. Specify the same name for the key that you used for the key pair (for example, aws-demo-key) and choose Save. PuTTY automatically adds the .ppk file extension.

To connect to your EC2 instance, follow the below steps:

1. Launch Putty.

2. In the Category pane, choose Session and complete the following fields:

  • In the Host Name box, enter ec2-user@Public IP or ec2-user@Public DNS(Copy it from EC2 Description).

  • Ensure that the Port value is 22.
  • Under Connection type, select SSH.

3. In the Category pane, expand Connection, expand SSH, and then choose Auth. Complete the following:

  • Choose Browse.
  • Select the .ppk file that you generated for your key pair and choose Open.
  • Choose Open.

4. 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.

5. SSH connection to your EC2 instance is established successfully.

Note: If you face any connection issue then check if you have all the required inbound rules defined in your security group.

Bijan Patel
Full Stack Test Automation Expert | Selenium Framework Developer | Certified Tosca Automation Specialist | Postman | DevOps | AWS | IC Agile Certified | Trainer | Youtuber | Blogger|

Launch your GraphyLaunch your Graphy
100K+ creators trust Graphy to teach online
𝕏
QASCRIPT 2024 Privacy policy Terms of use Contact us Refund policy