SSH
Amazon EC2
PuTTY
Windows
Cloud Computing

SSH to Amazon EC2 instance using PuTTY in Windows

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

Secure Shell (SSH) is a protocol that provides a secure channel over an unsecured network by using a client-server architecture, enabling secure connections to remote systems. Amazon Elastic Compute Cloud (EC2) instances allow users to deploy scalable web applications within the AWS cloud environment, and SSH provides a method to securely connect to an EC2 instance. This article will guide you through the process of connecting to an Amazon EC2 instance using the PuTTY SSH client on Windows.

Prerequisites

Before proceeding, ensure you have the following:

  1. PuTTY: A free and open-source terminal emulator program that acts as an SSH and Telnet client. You can download it from the official website.
  2. Amazon EC2 Instance: Make sure your instance is up and running. Ensure that the Security Group associated with your EC2 instance allows inbound SSH connections on port 22.
  3. Private Key File (.pem): The key pair generated and downloaded during the EC2 instance setup. This private key file is necessary for authentication and will be converted to a .ppk file for use with PuTTY.

Configuration Steps

Step 1: Convert .pem to .ppk

  1. Open PuTTYgen:
    • Launch PuTTYgen, which is included with PuTTY.
  2. Load your .pem file:
    • Click on "Load" in PuTTYgen.
    • Select "All Files" from the dropdown to display your .pem file.
    • Navigate to where the private key is stored and select your .pem file.
  3. Save the Private Key:
    • Click "Save private key".
    • A prompt will ask if you want to save without a passphrase. Choose “Yes,” but be aware that lacking a passphrase reduces security.
    • Save the resulting .ppk file in a secure location.

Step 2: Configure PuTTY for SSH Connection

  1. Open PuTTY:
    • Start PuTTY from your applications.
  2. Set Hostname and IP Address:
    • In the "Session" category, under "Host Name (or IP address)", input the public DNS or IP address of your instance (e.g., ec2-00-111-222-333.compute-1.amazonaws.com ).
  3. Specify the SSH Protocol:
    • Ensure the “Connection type” is set to SSH, which typically runs on port 22.
  4. Load the .ppk Key:
    • In the "Category" tree on the left, navigate to "Connection" > "SSH" > "Auth".
    • Click "Browse" button to select the .ppk file.
  5. Save the Session (Optional):
    • Return to the "Session" category.
    • Under "Saved Sessions", provide a name for this session and click "Save" to reuse it conveniently in the future.

Step 3: Connect to Your EC2 Instance

  1. Initiate the Connection:
    • Click "Open". If this is your first time connecting to this instance, PuTTY will display a security alert regarding caching the server's host key. Click "Yes" to proceed.
  2. Enter the Username:
    • When prompted, enter the appropriate username for your Linux instance:
      • For an Amazon Linux AMI, the user is ec2-user .
      • For a Ubuntu AMI, use ubuntu .
      • Other distributions have distinct usernames, such as root or centos .
  3. Access the Command Line Interface:
    • Upon successful login, you'll have access to the terminal of your EC2 instance.

Key Points Summary

StepDescription
Convert .pem to .ppkUse PuTTYgen to convert your .pem
file to .ppk
format.
Configure PuTTYSet hostname, select the SSH protocol, and load the .ppk key in PuTTY.
Connect to EC2 InstanceOpen the session, enter the username, and gain terminal access to your EC2.

Additional Tips

  • SSH Security: Consider applying additional security measures, such as enabling only specific IPs to access your instance or disabling password-based logins entirely.
  • Persistent Sessions: Utilize screen or tmux for managing persistent sessions in case of connection drops.
  • Automation: Explore PuTTY’s command line options to automate SSH connections for frequent access.
  • Troubleshooting: If SSH connection fails, verify that the EC2 Security Group settings allow inbound connections on port 22 and that the instance is configured with the correct permissions.

Understanding and applying these detailed steps will allow Windows users to securely manage computing resources hosted on Amazon EC2 using PuTTY. These practices ensure data security while providing flexibility and ease of access in a cloud environment.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.