AWS

3 Ways to Connect and SSH into an EC2 Instance – AWS

3 Ways to Connect and SSH into an EC2 Instance – AWS. In this guide you are going to learn how to connect to your EC2 instance from your local Linux or Mac or from your Windows machine.

3 Ways to Connect and SSH into an EC2 Instance

  1. Connect using a standalone SSH client.
  2. Connect using Session Manager.
  3. Connect using browser-based SSH connection.

Choose Best Hosting for your Business

PlatformReviewsPricing
Siteground★★★★★$3.95
Bluehost★★★★★$3.95
Kinsta – Google Cloud★★★★★$30

Prerequisites

  1. A running EC2 Instance. Learn how to create an AWS EC2 instance.
  2. Assigned a Elastic IP to your EC2 Instance.
  3. Pem key file downloaded when you have created your EC2 Instance.
  4. If you are on Windows and try the standalone method, you need PUTTY SSH client to connect to your Instance.

Before you connect to your EC2 instance make sure your IP address is added in the Firewall to allow connections from your IP address or your instance allows connection from anywhere.

Configure Security rules

Connect using browser-based SSH connection

This is the easiest way to connect yo your Instance instantly. This method don’t require any additional clients installed in your local machine. To use this method,

Select your Instance and click the Connect button in your EC2 Dashboard.

Browser Based SSH Connection

In the Connection method choose EC2 Instance Connect.

The username of the AMI will get populated automatically.

Now click Connect.

Now a new window will get opened and a connection will get established to your Instance.

If you get any errors you need to wait for sometime once your instance is created.

Connect to EC2 Instance from Linux/Mac machines

From your Linux/Mac machine you can simply open your terminal window, use the ssh command to connect to the instance. You specify the private key (.pem) file, the user name for your AMI (in this case it is ubuntu), and the public DNS name for your instance or your Elastic IP address.

The connection string looks similar to the one below.

ssh -i "cloudbooklet.pem" ubuntu@ec2-35-171-69-92.compute-1.amazonaws.com

Connect to EC2 Instance from Windows using PUTTY

To SSH to your instance you need to convert your private key (.pem) file using PUTTYgen to ppk format.

Open PUTTYgen and Click Load.

Convert private key to PPK

Select the pem key you have downloaded while created your instance.

Once the file is imported, click Save private key to convert it to ppk format.

Save the file.

Launch PUTTY.

Connect using PUTTY

In Hostname/IP address enter DNS name or Elastic IP address.

In Port enter default 22.

In the left menu under Connection expand SSH and click Auth.

Browse and select the PPK file you just converted using PUTTYgen.

Now click Open.

This will create an SSH connection to your EC2 Instance.

Conclusion

Now you have learned how to connect to your EC2 instance in AWS using standalone method or browser connection..

Thanks for your time. If you face any problem or any feedback, please leave a comment below.

Cloudbooklet builds a large collection of Linux based guides and tutorials on Cloud platforms like Google Cloud, AWS, Azure, DigitalOcean and more

Write A Comment

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.