Connecting to Linux EC2 Instances via SSH



This content originally appeared on DEV Community and was authored by Noor Fatima

Connecting to your Amazon EC2 Linux instances via SSH is a fundamental skill for managing your cloud infrastructure. Here’s a straightforward guide to help you get started with SSH access using Terminal (Mac/Linux) and PowerShell (Windows).

Using SSH with Terminal (Mac/Linux)

1. Open Terminal

Launch the Terminal application from your applications menu or by searching for it.

2. Run the SSH Command

Execute the following command to connect to your EC2 instance:

ssh -i /path/to/your-key.pem ec2-user@your-ec2-public-dns

  • Replace /path/to/your-key.pem with the path to your private key file.
  • Replace your-ec2-public-dns with the public DNS of your EC2 instance.

3. Key Permissions

Ensure your private key file has the correct permissions. You may need to set the permissions using:

chmod 400 /path/to/your-key.pem

Using SSH with PowerShell (Windows)

1. Open PowerShell

Open PowerShell from the Start menu or by searching for it.

2. Run the SSH Command

Execute the following command:

ssh -i C:\path\to\your-key.pem ec2-user@your-ec2-public-dns

  • Replace C:\path\to\your-key.pem with the path to your private key file.
  • Replace your-ec2-public-dns with your EC2 instance’s public DNS.


This content originally appeared on DEV Community and was authored by Noor Fatima