DEV Community

Cover image for Connecting to an EC2 Instance from a Windows Laptop: A Step-by-Step Guide
Alexand
Alexand

Posted on

1

Connecting to an EC2 Instance from a Windows Laptop: A Step-by-Step Guide

Introduction

Amazon EC2 allows users to run virtual servers in the cloud. If you have an EC2 instance running and need to access it from your Windows laptop, follow these steps to connect securely.

Index

Requirements Before You Start

  • An AWS account with an active EC2 instance
  • The key pair (.pem file) used when setting up the instance
  • Administrator access to your Windows laptop
  • The public IP address or DNS name of your EC2 instance

Step 1: Convert Your .pem Key to .ppk Format

Windows requires a different format for SSH connections. Since AWS provides .pem keys, they must be converted to .ppk format using PuTTYgen.

  1. Download PuTTYgen from the official website
  2. Open PuTTYgen and load your .pem file
  3. Click Save private key to store it as a .ppk file

Step 2: Install PuTTY

  1. Download PuTTY from the official website
  2. Run the installer and complete the installation

Step 3: Connect to Your EC2 Instance Using PuTTY

  1. Open PuTTY
  2. In the Host Name field, enter:
   ec2-user@your-instance-public-ip
Enter fullscreen mode Exit fullscreen mode

Replace your-instance-public-ip with the actual IP address. If your instance runs Ubuntu, replace ec2-user with ubuntu.

  1. In the left sidebar, navigate to Connection > SSH > Auth
  2. Click Browse, select your .ppk key, and connect
  3. If prompted with a security alert, click Yes to proceed

Alternative Method: Using Windows Subsystem for Linux (WSL)

Windows Subsystem for Linux (WSL) offers built-in SSH functionality without requiring PuTTY.

  1. Enable WSL by running this command in PowerShell (Administrator mode):
   wsl --install
Enter fullscreen mode Exit fullscreen mode
  1. Restart your computer
  2. Open the WSL terminal
  3. Navigate to the folder containing your .pem key
  4. Change permissions for security:
   chmod 400 your-key.pem
Enter fullscreen mode Exit fullscreen mode
  1. Connect using SSH:
   ssh -i "your-key.pem" ec2-user@your-instance-public-ip
Enter fullscreen mode Exit fullscreen mode

Troubleshooting Common Issues

Connection Timed Out

  • Verify that your EC2 instance is running
  • Check security group settings (ensure port 22 is open for SSH access)
  • Confirm the public IP address is correct

Permission Denied

  • Make sure you are using the correct username for your operating system
  • Ensure the correct key pair is selected
  • Check that the key file permissions are properly set

Server Refused the Key

  • Confirm that you are using the correct key pair
  • Ensure the key file was properly converted to .ppk format

Security Best Practices

  • Use SSH key pairs instead of passwords for authentication
  • Regularly rotate key pairs to enhance security
  • Restrict SSH access to trusted IP addresses only
  • Consider using AWS Systems Manager Session Manager instead of direct SSH for better security

Conclusion

Connecting to an EC2 instance from a Windows laptop is straightforward when using PuTTY or WSL. Once configured, accessing cloud servers securely becomes much easier.

For advanced setups, explore AWS Session Manager or configure SSH settings to simplify access to multiple instances.

Let me know if you need any clarifications or further guidance.

AWS GenAI LIVE image

Real challenges. Real solutions. Real talk.

From technical discussions to philosophical debates, AWS and AWS Partners examine the impact and evolution of gen AI.

Learn more

Top comments (1)

Collapse
 
shifa_2 profile image
Shifa

Very Clear Explanation, steps are making the things easy to understand

ITRS image

See What Users Experience in The Browser — Anywhere, Anytime

Simulate logins, checkouts, and payments on SaaS, APIs, and internal apps. Catch issues early, baseline web performance, and stay ahead of incidents. Easily record user journeys right from your browser.

Start Free Trial