How to Connect an EC2 Instance to an External Sources (Terminals)
Connecting an Amazon EC2 instance to external sources using SSH clients like PuTTY & MobaXterm is a fundamental skill for managing remote cloud resources. Here’s a step-by-step guide on how to set up and connect to your EC2 instance using PuTTY & MobaXterm .
Prerequisites
AWS Account – You need an AWS account with an EC2 instance already created and running you can this links for creating and launch an EC2 Instance
Key Pair File (.pem) – During the EC2 instance setup, AWS provides a key pair file (
.pem
). You’ll need this to connect to your instance.
Step-by-Step Guide
Step 1: Configure Security Groups
To ensure that your EC2 instance is accessible, the security group associated with it must allow incoming connections on port 22 (SSH). Here’s how to check and update the security group
Go to the EC2 Dashboard in the AWS Management Console.
Select Instances, and click on your instance to see its details.
Under Security, find the Security Groups section, and click on the linked security group.
In the security group details, select Edit inbound rules.
Add an Inbound rule for SSH with:
Type: SSH
Protocol: TCP
Port Range: 22
Source: Select either a specific IP (for increased security) or “Anywhere” (0.0.0.0/0) if you want open access.
Step 2: Installing PuTTY Software
We first need to install PuTTY
- For Installing PuTTY - Download Link
Step 3: Convert PEM to PPK Format
EC2 instances use a
.pem
key file for SSH access, but PuTTY requires the key to be in.ppk
format. Here's how to convert your key fileLaunch PuTTYgen Application on your system. PuTTYgen Application will automatically downloads with PuTTY Application.
Load Your PEM File
Click on the “Load” button.
Change the file type to display “All Files (.)” and select your
.pem
file.Keeping the Key passphase is optional.
Save the Private Key:
Step 4: Connect to EC2 Using PuTTY
Open PuTTY.
In the Host Name (or IP address) field, enter the Public DNS or Public IP of your EC2 instance. You can find this information in the EC2 Dashboard under Instance Details.
In the Category menu on the left, go to Connection > SSH > Auth.
Under the Auth section, go to the Credentials tab, then click Browse next to "Private key file for authentication" to locate and select your
.ppk
file.
- Click Open to start the connection.
Step 5: Log into the EC2 Instance
Once PuTTY connects to the instance, a terminal window will open. If you’re prompted with a security alert, accept it to proceed.
It will ask for login as "login as": it should be default user of an EC2 Instance
Passphrase for key "imported-openssh-key": One should provide key passphase provided during the step 3. while converting the
.pem
file to.ppk
file.For Reference: the default usernames for popular AMIs
Amazon Linux:
ec2-user
Ubuntu:
ubuntu
RHEL:
ec2-user
SUSE:
ec2-user
If the login is successful, you’re now connected to your EC2 instance using PuTTY!
Connecting an EC2 instance using PuTTY is a secure and effective way to manage your cloud resources remotely. This setup lets you work with and control your instance as if it were a local server, providing full administrative access.
Happy cloud computing!
Subscribe to my newsletter
Read articles from Uma Mahesh Tammineni directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by