>_ SSHDock
FeaturesHow it worksBlogGuidesAbout
Launch Terminal

How to SSH into AWS EC2

Amazon Web Services Elastic Compute Cloud. Learn how to securely connect to your server from any browser without installing native terminal apps like PuTTY or Termius.

Launch SSHDock

Connection Quick Reference

  • Default Username:ec2-user
  • Authentication:PEM Key

On this page

  • Prerequisites: Security Groups and Port 22
  • Identifying Your Public IPv4 Address
  • Locating the Correct Default Username
  • Handling the .pem Key File
  • Establishing the Connection with SSHDock
  • Troubleshooting Common AWS Connection Errors

Prerequisites: Security Groups and Port 22

Before you even attempt to connect to an Amazon EC2 instance, you must verify that the underlying network configuration allows inbound SSH traffic. Unlike local virtual machines, AWS instances are locked down by default via Security Groups.

When you launched your EC2 instance, you were prompted to select or create a Security Group. A Security Group acts as a virtual firewall at the instance level. If Port 22 (the standard SSH port) is blocked, every connection attempt will immediately result in a Connection timed out error, regardless of whether you have the correct key or IP address.

To verify your configuration, navigate to the EC2 Dashboard in the AWS Management Console. Select your running instance and look at the bottom panel. Under the Security tab, you will find the associated Security Groups. Click the group name, then check the Inbound rules.

You must see a rule that explicitly permits:

  • Type: SSH
  • Protocol: TCP
  • Port Range: 22
  • Source: 0.0.0.0/0 (for universal access) or your specific IP address.

If this rule is missing, click Edit inbound rules, add an SSH rule, and save it. The changes apply instantly to the running instance. No reboot is required.

Identifying Your Public IPv4 Address

Instances inside a VPC (Virtual Private Cloud) communicate via private IP addresses internally, but to reach them from the internet, you need their public IP.

On the EC2 Dashboard, click your instance. In the Details tab, locate the Public IPv4 address. It will look something like 54.123.45.67. Note that unless you have attached an Elastic IP, this public IP will change every time you stop and start the instance. (Rebooting does not change the IP, but fully stopping the instance does).

Locating the Correct Default Username

One of the most common reasons for Permission denied (publickey) errors on AWS is using the wrong username. Unlike traditional Linux servers where you often log in as root, AWS explicitly disables direct root logins for security reasons. Instead, you must log in using the default user associated with the AMI (Amazon Machine Image) you deployed.

Here are the standard default users for common AWS AMIs:

  • Amazon Linux 2 and 2023: ec2-user
  • Ubuntu Server: ubuntu
  • CentOS: centos
  • Debian: admin
  • SUSE Linux: ec2-user or root

If you attempt to log in as root on an Amazon Linux instance, the server will actually establish the connection briefly just to send back a message saying "Please login as the user ec2-user" before immediately closing the socket.

Handling the .pem Key File

AWS forces the use of key-based authentication. When you provision an instance, AWS requires you to select an existing key pair or generate a new one. If you chose to generate a new one, your browser downloaded a .pem file (e.g., my-production-key.pem).

This file is your private key. You cannot download it again from AWS. If you lose it, you will lose access to the instance entirely unless you mount the EBS volume to a secondary instance to recover it.

If you are using a native terminal on macOS or Linux, you must fix the permissions of this file before SSH will accept it. By default, downloaded files have open permissions, and the SSH daemon will reject the connection because the private key is "too open."

You would normally fix this by running: chmod 400 my-production-key.pem

However, because you are using SSHDock, you bypass this filesystem permission requirement entirely. SSHDock runs in the browser and handles the cryptographic handshake directly from the key string you provide, ignoring local OS file permissions.

Establishing the Connection with SSHDock

With your IP address, default username, and .pem file ready, establishing the connection through SSHDock is straightforward.

  1. Launch SSHDock and open the connection configuration panel.
  2. In the Host field, enter the Public IPv4 address of your EC2 instance.
  3. Leave the Port as 22 (unless you have custom-configured the sshd config on the server to listen on a non-standard port).
  4. In the Username field, enter the AMI-specific username (e.g., ec2-user or ubuntu).
  5. Select the Private Key authentication method.
  6. Open your downloaded .pem file in any text editor (like Notepad or TextEdit). Select everything (including the -----BEGIN RSA PRIVATE KEY----- and -----END RSA PRIVATE KEY----- boundaries) and paste it into the private key field. Alternatively, use SSHDock's file upload button to load the .pem file directly into the browser.
  7. Click Connect.

The SSH protocol requires the client to verify the identity of the remote host upon the first connection to prevent man-in-the-middle attacks. SSHDock will prompt you with the server's ECDSA or ED25519 fingerprint. Accept this fingerprint to store it locally and proceed with the connection.

Troubleshooting Common AWS Connection Errors

If the terminal fails to render a prompt, review these frequent failure points:

Connection Timed Out

This almost always indicates a network-level blockage. The TCP handshake never completed.

  • Check your AWS Security Group inbound rules for Port 22.
  • Ensure the instance is launched in a public subnet with an Internet Gateway attached to the VPC route table. If the instance is in a private subnet, you cannot connect directly from the public internet. You must use a Bastion Host or AWS Systems Manager Session Manager.

Permission Denied (publickey)

The server rejected your authentication attempt.

  • Wrong Username: Verify you are using ubuntu for Ubuntu, or ec2-user for Amazon Linux.
  • Wrong Key: Ensure the .pem file you pasted corresponds exactly to the key pair name listed in the EC2 Dashboard under the instance details.
  • Corrupted Key Format: If you pasted the key manually, ensure no trailing spaces or formatting characters were inadvertently added. The PEM format is strict.

Server Refused to Allocate PTY

This occasionally happens on severely resource-constrained micro instances (like t2.micro or t3.nano) running out of memory. If the server cannot allocate memory for a pseudo-terminal, the SSH connection drops immediately after authentication. Restarting the instance via the AWS Console is usually the only resolution.

Explore Other Integrations

DigitalOcean DropletGoogle Cloud Compute EngineMicrosoft Azure Virtual MachineLinode Compute InstanceVultr Cloud Compute
SSHDOCK

Full terminal in your browser. Local credential storage, jump host tunneling, live CPU/memory/disk metrics, and a mobile soft-key bar. Free to use. Built by developers, for developers.

© 2026 SSHDock

GitHub (@ayanhackspro)
App
Launch TerminalFeaturesHow it worksBlog & TutorialsChangelogGuides
Cloud Guides
AWS EC2DigitalOcean DropletGoogle Cloud Compute EngineMicrosoft Azure Virtual MachineLinode Compute InstanceVultr Cloud Compute
Legal & Contact
Privacy PolicyTerms of ServiceDisclaimerContact UsAbout Creator
Modern, minimal browser SSH client
TerminalSitemap