How to SSH Into EC2 Instances

I have a windows device, so the examples below actually worked for me using a Windows 11 device:

1. PuTTY
2. Windows Powershell
3. Command Prompt

PuTTY

PuTTY is a free and open-source SSH client for Windows, widely used for connecting to remote systems securely. Here’s how to use PuTTY to SSH into your AWS EC2 instance:

  1. Download PuTTY from the official website: PuTTY Download Page
  2. Launch PuTTY and enter your EC2 instance’s public DNS or IP address in the “Host Name (or IP address)” field.
  3. Under the “Connection” category in the left sidebar, expand the “SSH” option and click on “Auth.”
  4. Click on the “Browse” button and select the private key file (.pem) associated with your EC2 instance.
  5. Return to the “Session” category, enter a name for your session in the “Saved Sessions” field, and click “Save” to save your configuration.
  6. Click “Open” to initiate the SSH connection. If prompted, click “Yes” to accept the server’s SSH key fingerprint.
  7. You’ll be prompted to enter the username for your EC2 instance. Depending on the Linux distribution, common usernames include “ec2-user” for Amazon Linux, “ubuntu” for Ubuntu instances, and “admin” or “root” for other distributions.

Windows Powershell

Windows PowerShell provides a powerful command-line interface for managing Windows and, with additional modules, for interacting with AWS services. Here’s how to use Windows PowerShell to SSH into your EC2 instance:

  1. Open Windows PowerShell.
  2. Get into the working directory of where the .pem key file is stored on your Windows device. To do this, you will enter the current working directory of your file.
  3. Use the ssh command followed by the EC2 instance’s username and public DNS or IP address:

Replace /path/to/private-key.pem with the path to your private key file and username with the appropriate username for your EC2 instance.

In my cade my input looks something like this:

Command Prompt

Command Prompt (cmd) is a basic command-line interpreter available on Windows systems. You can use it to run SSH commands similar to Windows PowerShell. Here’s how:

  1. Open Command Prompt (cmd).
  2. Use the ssh command followed by the EC2 instance’s username and public DNS or IP address, similar to Windows PowerShell:
  1. Replace /path/to/private-key.pem with the path to your private key file and username with the appropriate username for your EC2 instance.

Using one of these methods, you can securely SSH into your AWS EC2 instances from your Windows machine. Choose the method that best fits your preferences and workflow, and start managing your EC2 instances with ease. Happy coding!

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top