How to Connect to an EC2 Instance Using SSH (2024)

Hire us

  • By Alfonso Valdes
  • December 16, 2022
  • Amazon EC2, AWS

How to Connect to an EC2 Instance Using SSH (35)

Have you ever launched an EC2 instance and don’t know how to log in to your brand-new instance? It may sound difficult if you are a beginner, but it’s pretty much simple. Let’s take a look at how to connect to an EC2 instance using SSH, following the next simple steps whether you are using Linux or Windows.

Table of content

  • Requirements
  • How to connect to an EC2 instance using SSH using Linux
  • How to connect SSH into EC2 instance using SSH using Windows
  • Conclusion

Requirements

  • SSH Key (.pem file) provided by Amazon.This SSH key is provided by Amazon when you launch the instance.
  • IP address. IP address assigned to your EC2 instance.
  • Username.The username depends on the Linux distro you just launched. Usually, these are the usernames for the most common distributions:

-Ubuntu: ubuntu

-Amazon Linux: ec2-user

-Centos: root

Only for Windows Users

How to connect to an EC2 instance using SSH using Linux

1.Open your terminal and change directory with command cd, where you downloaded your pem file. In this demonstration, pem file is stored in the downloads folder.

How to Connect to an EC2 Instance Using SSH (37)

2.Type the SSH command with this structure:

ssh -i file.pem username@ip-address 

This is the explanation of the previous command:

  • ssh: Command to use SSH protocol
  • -i: Flag that specifies an alternate identification file to use for public key authentication.
  • username: Username that uses your instance
  • ip-address: IP address given to your instance

3.After pressing enter, a question will prompt to add the host to your known_hosts file. Type yes. This will help to recognize the host each time you’re trying to connect to your instance.

How to Connect to an EC2 Instance Using SSH (38)

4.And that’s it! Now you’re logged in on your AWS instance

How to Connect to an EC2 Instance Using SSH (39)

How to connect SSH into EC2 instance using SSH using Windows

1.Open your PuttyGen (it is included with your Putty Client installation) on your PC.

How to Connect to an EC2 Instance Using SSH (41)

2.Make sure the checkbox “RSA” is selected.

How to Connect to an EC2 Instance Using SSH (42)

3.Click load and go to the folder where you have stored your pem file, select it and choose open.

How to Connect to an EC2 Instance Using SSH (43)
How to Connect to an EC2 Instance Using SSH (44)

4.You will see this message.

How to Connect to an EC2 Instance Using SSH (45)

Click OK

5.After the Key is loaded, click on save private key. Then a message will prompt, select yes.

How to Connect to an EC2 Instance Using SSH (46)

6.Now type a name for your key. For this example, the key will be named “instance” (it is not necessary to add the .ppk to the name file, Putty will do it)

How to Connect to an EC2 Instance Using SSH (47)

7.Now close PuttyGen program and open Putty. Go to SSH section and double-click it.

How to Connect to an EC2 Instance Using SSH (48)

8.Go to Auth section and select the ppk file that we just created.

How to Connect to an EC2 Instance Using SSH (49)

9.Go back at the top in the Session section. Fill the field Hostname (or IP address) with the IP address given to your AWS instance and click open.

How to Connect to an EC2 Instance Using SSH (50)

10.A warning will prompt. The server host is not registered on our PC, so we must add it. Click yes.

How to Connect to an EC2 Instance Using SSH (51)

11.A window will prompt asking for the username, type your distro username, in this demonstration, username is ubuntu.

How to Connect to an EC2 Instance Using SSH (52)

12.And there you go! Now you’re connected to your AWS instance using Putty on your Windows OS.

How to Connect to an EC2 Instance Using SSH (53)

You might also like:What is AWS ECS? – Run Docker in Production

Conclusion of How to Connect to ec2 Instance SSH

As you can see, the steps to connect to EC2 instance SSH are quite simple, but sometimes we can mess up the SSH conversion on Windows or how to get your instance information. In case that happens or you forget any step, feel free to come back and take a look at this tutorial on how to connect to Amazon EC2 instance ssh.

Now you will not be facing doubts the next time you launch your amazing AWS instances. Perhaps you want to take a look at how much you will spend on these brand-new instances; feel free to readHow AWS Pricing worksor read more awesome blogs on our website!

Remember that ClickIT is always ready to help you; we’ll find the best AWS solution for your business!

Also read: AWS Security Tools

This blog is also available on our DZone profile

FAQs

What is Amazon EC2?

EC2 (Elastic Cloud Compute) is a service where you can create servers to launch your websites or applications. One of the first things you will find when you create an EC2 instance is the instance type/size. Learn more about creating and choosing the best EC2 instance for your project here.

Why use Amazon EC2?

Since many other providers on the network can host your app, we choose Amazon EC2 because it offers a lot of possibilities. You can start with a small instance, then, when you get more traffic, grow it up to a bigger option, making EC2 more flexible and adaptable than other technologies to host your application.

What are the characteristics of an EC2?

– High availability level.
– High-reliability level.
– Scalable in memory space and server size.
– The hard disk space is independent of the instance size, so it can be set according to your requirements and increased using the AWS service EBS (Elastic Block Store).
– It offers “double” security since, in addition to the default firewall, AWS Security Groups restrict the ports you prefer.

Why use an SSH key?

Secure Socket Shell (SSH) enables public-key-based authentication and facilitates encrypted connections between two endpoints in a network. Generating SSH keys to access containers and servers is highly recommended for ​​securing your IT resources, and it is one of many DevOps security best practices.

Subscribe

to our newsletter

Table of Contents

We Make DevOps Easier

Get an assessment

Weekly DevOps Newsletter

Subscribe

nearshore

Staff Augmentation vs Consulting: Choose your 2024 Strategy

In 2024, companies are prioritizing strong and trustworthy teams. More than ever, organizations focus on building an IT staff that aligns with their values and

Read More »

March 7, 2024

AWS

AWS RDS vs Aurora: The Battle of Databases

Ever wondered how the right database could be the secret sauce to supercharge your cloud applications? Well, AWS has got you covered with Amazon RDS

Read More »

February 22, 2024

DevOps

Decoding MLOps vs DevOps: What is the Difference?

With artificial intelligence and machine learning technologies becoming an integral part of most business operations, MLOps vs DevOps has become a point of debate in

Read More »

February 15, 2024

How to Connect to an EC2 Instance Using SSH (2024)

FAQs

How do I connect to my EC2 instance via SSH? ›

Step-by-Step Guide to Connect to EC2 Instance Using SSH
  1. Step 1: Retrieve Your Instance Information. First, log in to your AWS Management Console and navigate to the EC2 dashboard. ...
  2. Step 2: Set Permissions for Your Key File. ...
  3. Step 3: Connect Using SSH. ...
  4. Step 4: Verify the Connection.
Nov 15, 2023

Why am I unable to SSH into an EC2 instance? ›

Check your VPC settings: Make sure that your VPC settings are correct. If you are using a custom VPC, make sure that it is properly configured. Check the network ACL settings: Network ACLs are another layer of security in your VPC. Make sure that your network ACLs allow incoming traffic on port 22.

How do I troubleshoot problems connecting to my Amazon EC2 Linux instance using SSH? ›

Resolution
  1. Open the Amazon EC2 console.
  2. Choose Instances.
  3. Select the instance, then choose Actions, Monitor and troubleshoot, EC2 Serial Console, Connect. ...
  4. Press Enter. ...
  5. At the login prompt, enter the username of the password-based user that you set up previously, and then press Enter.

How do you login to an AWS EC2 instance using key pair for SSH? ›

Method 1: Enter user-data
  1. Create a new key pair.
  2. If you create the private key in the Amazon EC2 console, then retrieve the public key for the key pair.
  3. Open the Amazon EC2 console.
  4. Stop your instance.
  5. Replace username with your user name, such as ec2-user. ...
  6. Start your instance.

How do you login to AWS EC2 instances? ›

  1. Connect to your Linux instance. Connect with SSH from Linux or macOS. ...
  2. Connect to your Windows instance. Connect to your Windows instance using an RDP client. ...
  3. Connect using Session Manager.
  4. Connect using EC2 Instance Connect Endpoint. Permissions. ...
  5. Connect your instance to a resource.

How to login to EC2 without SSH? ›

How to Securely Connect to AWS EC2 without SSH Keys
  1. Step 1: Create a IAM Role For EC2 Instance.
  2. Step 2: Attach IAM Role To EC2 Instance.
  3. Step 3: connecting to EC2 server via Session Manager.
  4. Frequently Asked Questions for AWS EC2 Connection without SSH Key.
  5. Conclusion.
Dec 2, 2023

Why can't i connect to a remote server SSH? ›

Wrong credentials – double-check for typos when writing your username, password, and IP address. SSH client is set incorrectly – ensure you enable a command prompt on your terminal window or use PuTTY. No SSH Daemon installed on the server side – make sure you have installed it to access the remote server.

Which port is required for SSH connection to EC2 instance? ›

The direct connection via SSH to an EC2 instance requires the Security Group to have TCP port 22 open. In addition to the port, the instance must have a Public IP or an Elastic IP address and is reachable from the Internet.

Why is my SSH connection not working? ›

Typos or incorrect credentials are common reasons for a refused SSH connection. This includes errors in the specified username or password, or wrong IP address.

Why is my new EC2 instance not connecting? ›

The EC2 Instance Connect package isn't installed on the instance. There are missing or incorrect AWS Identity and Access Management (IAM) policies or permissions. Security groups that are associated with the instance don't list EC2 Instance Connect service IP addresses. The network access or configuration is incorrect.

Why is my Linux server not accepting SSH connections? ›

Incorrect SSH Credentials or Port Configuration

Incorrect SSH credentials or port configuration can also result in the “Connection Refused” error. Typos or inaccuracies in the SSH username, password, hostname, or port can cause the server to reject the connection request, triggering the error message.

How do I connect to ec2 from terminal? ›

How to connect to an EC2 instance using SSH using Linux
  1. Open your terminal and change directory with command cd, where you downloaded your pem file. ...
  2. Type the SSH command with this structure: ssh -i file.pem username@ip-address. ...
  3. After pressing enter, a question will prompt to add the host to your known_hosts file.

What is ec2 instance connect endpoint? ›

Amazon EC2 Instance Connect Endpoint (EIC Endpoint) allows a secure connection to the instances in a private subnet from the internet. It does not require a bastion host, internet gateway in VPC, a public IP address on the resource, or even any agent to connect to the resource.

How do I connect to EC2 from local terminal? ›

Use the Amazon EC2 console to connect (only for instances with IPv4 Public address)
  1. Open the Amazon EC2 console.
  2. In the navigation pane, choose Instances.
  3. Select the instance, and then choose Connect.
  4. Choose EC2 Instance Connect.
  5. Verify the username, and then choose Connect to open a terminal window.

How to connect EC2 instance using PuTTY without PEM file? ›

How to Connect to AWS EC2 Instance by Using PuTTY Without Using . pem File?
  1. Step 1: Enable Password Authentication on EC2 Instance. Log in to your AWS Management Console. ...
  2. Step 2: Set Password for User. ...
  3. Step 3: Restart the SSH Server. ...
  4. Step 4: Configure PuTTY. ...
  5. Step 5: Session Save. ...
  6. Step 6: Establish a Connection.

Top Articles
Card Benefits | Visa Signature® Max Cash Preferred Card
Best Email Organization Strategies For A Clean Inbox In 2024
No Hard Feelings (2023) Tickets & Showtimes
It's Official: Sabrina Carpenter's Bangs Are Taking Over TikTok
Using GPT for translation: How to get the best outcomes
Mileage To Walmart
Videos De Mexicanas Calientes
EY – все про компанію - Happy Monday
His Lost Lycan Luna Chapter 5
Günstige Angebote online shoppen - QVC.de
Funny Marco Birth Chart
111 Cubic Inch To Cc
Sonic Fan Games Hq
Der Megatrend Urbanisierung
Dark Chocolate Cherry Vegan Cinnamon Rolls
Trivago Sf
UPS Store #5038, The
Heart and Vascular Clinic in Monticello - North Memorial Health
O'Reilly Auto Parts - Mathis, TX - Nextdoor
Zillow Group Stock Price | ZG Stock Quote, News, and History | Markets Insider
27 Paul Rudd Memes to Get You Through the Week
Getmnapp
Prep Spotlight Tv Mn
What Equals 16
At 25 Years, Understanding The Longevity Of Craigslist
Soul Eater Resonance Wavelength Tier List
Relaxed Sneak Animations
10-Day Weather Forecast for Santa Cruz, CA - The Weather Channel | weather.com
Japanese Emoticons Stars
Bj's Tires Near Me
Trust/Family Bank Contingency Plan
Grove City Craigslist Pets
2015 Chevrolet Silverado 1500 for sale - Houston, TX - craigslist
Chase Bank Cerca De Mí
A Man Called Otto Showtimes Near Carolina Mall Cinema
Montrose Colorado Sheriff's Department
Babbychula
Ksu Sturgis Library
Td Ameritrade Learning Center
„Wir sind gut positioniert“
More News, Rumors and Opinions Tuesday PM 7-9-2024 — Dinar Recaps
Ursula Creed Datasheet
Casamba Mobile Login
Cult Collectibles - True Crime, Cults, and Murderabilia
Contico Tuff Box Replacement Locks
Yosemite Sam Hood Ornament
Diario Las Americas Rentas Hialeah
Bluebird Valuation Appraiser Login
Arre St Wv Srj
Craigslist Farm And Garden Missoula
Latest Posts
Article information

Author: Geoffrey Lueilwitz

Last Updated:

Views: 6808

Rating: 5 / 5 (80 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Geoffrey Lueilwitz

Birthday: 1997-03-23

Address: 74183 Thomas Course, Port Micheal, OK 55446-1529

Phone: +13408645881558

Job: Global Representative

Hobby: Sailing, Vehicle restoration, Rowing, Ghost hunting, Scrapbooking, Rugby, Board sports

Introduction: My name is Geoffrey Lueilwitz, I am a zealous, encouraging, sparkling, enchanting, graceful, faithful, nice person who loves writing and wants to share my knowledge and understanding with you.