3.20 EC2 Instance connect AWS
Imagine you cannot connect over SSH using any of the tools we have seen previously — no working terminal, no PuTTY profile, no Windows OpenSSH. The AWS console offers an alternative built right into the EC2 service: EC2 Instance Connect. Open the instance, click Connect, and you are presented with several options including a standalone SSH client, AWS Session Manager, and EC2 Instance Connect itself.
Using EC2 Instance Connect
- Select the EC2 Instance Connect tab in the connection dialog.
- Keep the default user (
ec2-userfor Amazon Linux 2 AMIs). - Click Connect — a terminal opens directly in the browser.
Behind the scenes, the console generates a temporary SSH key pair on the fly, valid only for this session. The public key is pushed to the instance through the AWS metadata service, and the browser uses the matching private key to open the SSH session. You never have to download, store, or rotate a key yourself — AWS handles the whole rotation transparently.
Once inside the session, the behavior is identical to a standard SSH session: you can run whoami, uname -a, install packages, or browse files. EC2 Instance Connect is convenient when you have lost your private key, need quick browser-only access, or want to give a junior engineer temporary access without distributing credentials. It is fast, simple, and requires no extra setup beyond the right IAM permission to call the EC2 Instance Connect API.
Summary
EC2 Instance Connect is a browser-based method to connect to your EC2 instances directly from the AWS Console when SSH or other traditional connection methods are unavailable. The service automatically generates a temporary SSH key for each session, eliminating the need to manually manage SSH key pairs. This approach is fast, simple, and requires no local SSH client or key configuration—you can launch a terminal session directly in your browser.
Key points
- Access EC2 Instance Connect from the AWS Console without managing SSH keys
- AWS Console generates a temporary SSH key on-the-fly for each connection session
- Connect using the default user of your AMI (e.g., 'ec2-user' for Amazon Linux 2)
- Run the same commands as you would in a terminal or SSH client
- No need to install SSH clients or configure key pairs locally
- Fast and convenient browser-based access from any device with internet access
FAQ
What is EC2 Instance Connect and when should I use it?
EC2 Instance Connect is a feature that allows you to connect to EC2 instances directly through the AWS Console. Use it when you cannot access your instance via SSH, or when you prefer a quick browser-based connection without managing SSH keys.
Do I need an SSH key pair to use EC2 Instance Connect?
No. EC2 Instance Connect automatically generates a temporary SSH key for each session, so you don't need to manage or configure SSH key pairs manually.
What commands can I run through EC2 Instance Connect?
You can run any command you would normally execute in a terminal or SSH client, using the default user account of your AMI (such as 'ec2-user' for Amazon Linux 2).