DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • regreSSHion: Should We Panic About the New OpenSSH Vulnerability?
  • Linux Mint Debian Edition Makes Me Believe It’s Finally the Year of the Linux Desktop
  • EC2 Instances With SSH, WinSCP, and PuTTY [Videos]
  • How to Install VPN on Linux?

Trending

  • A Developer's Guide to Mastering Agentic AI: From Theory to Practice
  • Testing SingleStore's MCP Server
  • Unlocking the Potential of Apache Iceberg: A Comprehensive Analysis
  • Unlocking AI Coding Assistants Part 3: Generating Diagrams, Open API Specs, And Test Data
  1. DZone
  2. Coding
  3. Tools
  4. How To Connect to an EC2 Instance Using SSH

How To Connect to an EC2 Instance Using SSH

Have you ever launched an EC2 instance? Whether you are using Linux or Windows, here's a quick guide to connecting to an EC2 instance using SSH.

By 
Alfonso Valdes user avatar
Alfonso Valdes
·
Nov. 07, 23 · Tutorial
Likes (2)
Comment
Save
Tweet
Share
2.9K Views

Join the DZone community and get the full member experience.

Join For Free

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.

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

  • Putty SSH Client installed on your PC. You can download the latest version.

How To Connect to an EC2 Instance Using SSH Using Linux

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

connect to ec2 instance ssh using linux step 1

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

connect to ec2 instance ssh using linux step 3

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

AWS instance

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.

connect ssh into ec2 instance using windows step 1

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

connect ssh into ec2 instance using windows step 2

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

connect ssh into ec2 instance using windows step 3a
connect ssh into ec2 instance using windows step 3b

4. You will see this message.

connect to ec2 instance ssh using windows step 4

Click OK

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

connect to ec2 instance ssh using windows step 56. 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)
connect to ec2 instance ssh using windows step 6

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

connect to ec2 instance ssh using windows step 7

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

connect to ec2 instance ssh using windows step 8

9. Go back to 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.

connect to ec2 instance ssh using windows step 9

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

connect to ec2 instance ssh using windows step 10


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

connect to ec2 instance ssh using windows step 11

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

Now, you’re connected to your AWS instance using Putty on your Windows OS.

Conclusion of How To Connect to EC2 Instance SSH

As you can see, the steps 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 EC2 instance ssh.

Now, you will not be facing doubts the next time you launch your amazing AWS instances.

AWS PuTTY Linux (operating system) ubuntu

Published at DZone with permission of Alfonso Valdes. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • regreSSHion: Should We Panic About the New OpenSSH Vulnerability?
  • Linux Mint Debian Edition Makes Me Believe It’s Finally the Year of the Linux Desktop
  • EC2 Instances With SSH, WinSCP, and PuTTY [Videos]
  • How to Install VPN on Linux?

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!