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
- Connect using a standalone SSH client.
- Connect using Session Manager.
- Connect using browser-based SSH connection.
- A running EC2 Instance. Learn how to create an AWS EC2 instance.
- Assigned a Elastic IP to your EC2 Instance.
- Pem key file downloaded when you have created your EC2 Instance.
- 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.
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.
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" firstname.lastname@example.org
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.
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.
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.
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.