What is SSH?
Secure Shell (SSH) is a method that lets you securely connect to and control a remote computer or server over the internet. When using AWS EC2 (Amazon's cloud servers), SSH allows you to remotely log in to your EC2 instance from your computer, so you can run commands, install software, and manage the server.
Here’s how it works in AWS EC2:
- Launch an EC2 instance: When you create an EC2 server on AWS, it runs in the cloud.
- SSH Key Pair: During setup, you generate or use an existing SSH key pair (public and private key). AWS keeps the public key on the EC2 instance, and you download the private key to your computer (a
.pemfile). - Connect to EC2 with SSH: You use the private key to connect securely to your EC2 instance from your local terminal using this command: ssh -i /path/to/your-key.pem ec2-user@your-ec2-public-ip
- This lets you manage the EC2 server securely from anywhere, as long as you have your private key.

Diagram illustrating how SSH works between a local machine and an AWS EC2 instance. It shows the secure connection established using SSH keys, with a private key on the local machine and a public key on the EC2 instance. The lock icon highlights the encrypted communication between the two.
