The official AWS documentation instructs you to install PuTTY, convert your .pem file to .ppk format with PuTTYgen, configure a session, and connect. That works fine if you are sitting at your own Windows desktop with admin rights. It falls apart when you are on a borrowed laptop, a Chromebook, or a managed corporate machine where you cannot install software.
Here is how to connect directly from your browser, with no installation required.
What you need before you start
You need three things: your EC2 instance's public IP address or DNS name, the .pem private key file that AWS gave you when you launched the instance, and a browser-based SSH client. This guide uses SSHDock, which runs entirely in the browser tab.
About the .pem file: When you launch an EC2 instance, AWS creates a key pair and gives you the private key as a .pem download. This is a one-time download. If you close that dialog without saving it, or if you lose the file, you cannot recover it. AWS does not store your private key.
If you lost the .pem file, you have a few options depending on your situation. If you still have access to the instance through another method (like another key or AWS Systems Manager Session Manager), you can add a new public key to ~/.ssh/authorized_keys. If you have no access at all, you will need to stop the instance, detach the root volume, attach it to a recovery instance, mount it, add a new authorized key, and reattach everything. That process works but takes time. Save your keys somewhere safe.
Step 1: Find your instance's connection details
Log into the AWS console and navigate to EC2, then Instances. Click your instance name. In the details panel at the bottom, you will see:
- Public IPv4 address or Public IPv4 DNS — either works as the hostname
- Key pair name — confirms which
.pemfile you need - AMI — tells you the default username
The default username varies by AMI:
| AMI | Default username |
|---|---|
| Amazon Linux 2 / Amazon Linux 2023 | ec2-user |
| Ubuntu | ubuntu |
| Debian | admin |
| RHEL / CentOS | ec2-user |
| Fedora | fedora |
| SUSE | ec2-user |
If you are using a custom AMI from the Marketplace, the documentation for that AMI will tell you the username. When in doubt, try ec2-user and ubuntu first.
Step 2: Check your security group
Before you open any SSH client, verify that port 22 is actually open for your IP address. This is the most common reason connections fail.
In the instance details, click the Security tab, then click the security group name. You will see the inbound rules. You need a rule that allows TCP port 22 from your current IP address, or from 0.0.0.0/0 if you want to allow any IP.
To find your current public IP, visit whatismyip.com or run:
curl ifconfig.me
If there is no inbound rule for port 22, add one. If there is a rule but it lists a different IP, update it. The rule needs to match the IP that your browser is connecting from, not the IP of your machine on a local network.
Step 3: Open SSHDock in your browser
Go to sshdock.com/app. The connection form loads directly, no account required.
Step 4: Enter your connection details
In the connection form:
- Hostname: your instance's public IPv4 address or DNS name
- Port: 22 (unless you changed it)
- Username: the appropriate user for your AMI (see the table above)
Step 5: Add your private key
Click the key button or the "Add private key" option. Open your .pem file in any text editor and copy the entire contents, including the header and footer lines:
-----BEGIN RSA PRIVATE KEY-----
MIIEowIBAAKCAQEA...
...rest of the key...
-----END RSA PRIVATE KEY-----
Or for newer keys generated with OpenSSH:
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAA...
-----END OPENSSH PRIVATE KEY-----
Paste the full contents into the key field. SSHDock stores this in your browser's local storage. The key stays on your machine and is not transmitted to any server.
Step 6: Connect
Click Connect. If your security group is correct and your key matches, you will get a terminal prompt within a few seconds. You should see something like:
Last login: Thu Sep 26 10:15:23 2026 from 123.456.789.0
__| __|_ )
_| ( / Amazon Linux 2023
___|\___|___|
https://aws.amazon.com/linux/amazon-linux-2023
ec2-user@ip-172-31-12-34:~$
Troubleshooting connection failures
Connection timed out: Almost always a security group issue. The traffic is not reaching your instance. Double-check that port 22 is open in the inbound rules for your current IP.
Permission denied (publickey): The key is not matching. Possible reasons:
- You are using the wrong username for your AMI
- You are using the wrong
.pemfile (if you have multiple key pairs) - The key format did not copy correctly — make sure you included the header and footer lines
Host key verification failed: Rare with SSHDock, but if you see it, the instance may have been stopped, its IP reassigned, and a new host key generated. This happens when you stop and start an instance (not reboot). The public IP changes and the host key changes.
Connection refused: Port 22 is reachable but SSH is not running. This can happen if the instance is starting up and the SSH daemon has not started yet, or if SSH was stopped on the instance.
Connecting to instances in private subnets
Many production AWS architectures put EC2 instances in private subnets with no public IP address. Those instances are not directly reachable from the internet. The standard approach is a bastion host (also called a jump server) in a public subnet that you SSH into first, then jump from there to the private instance.
SSHDock supports this through its jump host feature. In the connection form, expand the "Jump Host" section and enter:
- Jump hostname: the public IP of your bastion instance
- Jump username: the bastion's username (often
ec2-userorubuntu) - Jump key: the key for the bastion (can be the same key as the target instance if you used the same key pair for both)
SSHDock handles the tunnel automatically. You connect to the bastion first, then SSHDock tunnels through it to the private instance. This is the same thing ssh -J does on the command line.
See our bastion host guide for more detail on setting up the architecture, including how to use a single bastion to access multiple private instances.
Security considerations
Your private key stays in your browser's localStorage. It does not go through any relay server. The SSH connection travels directly from your browser to your EC2 instance, encrypted end-to-end.
That said, browser local storage is not the same as an encrypted key vault. If you are on a shared or public machine, clear your browser data when you are done, or use the "Remove Key" option in SSHDock before you close the tab. A different user on the same browser profile could potentially retrieve the key from local storage.
For production servers, also consider whether port 22 needs to be open to the internet at all. If your team's IP addresses are predictable, restricting inbound SSH to those specific CIDR ranges in the security group significantly reduces exposure to automated scans. If you need more control, AWS Systems Manager Session Manager lets you connect to EC2 instances without port 22 open at all, using IAM permissions instead.
Updating your key pair for future access
If you want to add a second public key to an instance (for a team member, or to avoid relying on the original .pem), connect to the instance and edit ~/.ssh/authorized_keys. Each line is one public key. Append the new public key on a new line. The next connection using that key will work without any changes to the security group.