Skip to main content

1. How to connect SSH into EC2 Instance

  1. Once instance is launched, Select EC2 Instance Connect option and click on Connect button.(Keep everything else as default
  1. A new tab will open in the browser where you can execute the CLI Commands.

2. MAC & Linux Users

  1. Open Terminal application in your local system.
  2. Navigate to the location where .pem key is downloaded and stored in your local.
  3. To update Permissions, run command
    • Syntax : chmod 400 keypair_filename
    • Example : chmod 400 ec2_connect.pem
  4. User Name of the server :
    • Amazon Linux AMI : ec2-user
    • Ubuntu AMI : ubuntu
    • OPENVPN AMI : root
  5. To SSH and connect to the EC2 Instance, Enter the following command:
    • Syntax : ssh -i keypair_filename UserName**@**publicIPAddress (enter the username and public IP address)
    • Example : ssh -i ec2_connect.pem ec2-user@54.172.93.175 —> Click Enter
    • Up next, type yes and Enter, you will be successfully logged into EC2 Instance.

3. SSH into EC2 instance for Windows (10,11) Users in command prompt and PowerShell

  1. For this method, you have to use PEM file from the EC2 Instance.
  2. Once instance is launched, click on connect button and go to SSH client section.
**3.**Now you can see an example in below for SSH client key, copy the key we will use it later. 4.Open command prompt or PowerShell in your windows. 5. You have to check where the PEM file has downloaded in your local. In my case its in downloads section. 6. Change your path to downloads section. Example of command <cd downloads> 7. The key which you have copied, we have to use now ssh -i “<your pem file name>” ec2-user@ec2-<your ip address>.compute-1.amazonaws.com 8. we have successfully connected to ec2 instance via windows PowerShell. 4. Microsoft Windows Users( Putty)
  1. Download putty and puttygen from this link : https://www.chiark.greenend.org.uk/~sgtatham/putty/releases/0.74.html
  2. To convert your key pair .pem to .ppk.
    • Open PuttyGen.
    • Click on Load
    • Click on All files to show your .pem file and select the .pem keypair file.
    • And Click on open, You will get uccess message if done correctly.
  • Click on the Save Private Key button.
  • Enter keypairname and Save.
  • keypairname.ppk file will be saved to your local machine.
  1. Navigate to the EC2 instance page and get the public IP of the machine.
  2. Open Putty
    • Host Name : Enter the public IP address.
    • Click , select ,and again click credentials, then to select the private key (.ppk) that you converted from the .pem file.
    • Click on .
  • Select accept to connect to the machine
  1. If you are using Amazon Linux AMI for the lab:
    • Enter user name: ec2-user and hit Enter.
  1. If you are using Ubuntu AMI for the lab:
    • Enter user name: ubuntu and hit Enter.
  2. If you are using OPENVPN AMI for the lab:
    • Enter user name: root and hit Enter.
  3. You will see the console after a successful login.