Prerequisites

To connect to an EC2 instance, you need three things:


Default Usernames by OS

Operating System Default Username
Amazon Linux ec2-user
Ubuntu ubuntu
Red Hat ec2-user
Debian admin
Windows Administrator

Method 1: SSH on Windows (Git Bash / PowerShell)

Windows 10/11 has SSH built-in. You can also use Git Bash.

Steps:

# Step 1: Navigate to where your PEM file is saved
cd Downloads

# Step 2: Set correct permissions (recommended)
chmod 400 your-key.pem

# Step 3: Connect
ssh -i your-key.pem ubuntu@<EC2-Public-IP>

Real example:

ssh -i mykey.pem ubuntu@13.235.45.67

Command breakdown:

Part Meaning
-i Specify the identity (key) file
your-key.pem Your downloaded private key file
ubuntu Username (depends on AMI)
13.235.45.67 EC2 public IP address

Method 2: SSH on Linux / macOS

Steps: