> ## Documentation Index
> Fetch the complete documentation index at: https://cloud-architect.ipoint-labs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SSH into an EC2 instance

> Help for Cloud Practitioner labs

## 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

<img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/001.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=6e980b52fe1e15ef8014b726ac957ae3" alt="" width="751" height="531" data-path="images/labs/support/ssh-into-ec2-instance/001.png" />

2. A new tab will open in the browser where you can execute the CLI Commands.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/002.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=2589bd8a6478364cd6be5a8249286268" alt="" width="746" height="207" data-path="images/labs/support/ssh-into-ec2-instance/002.png" />

## 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**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/003.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=9c8e9e664b51e7e914a4081868abd249" alt="" width="609" height="101" data-path="images/labs/support/ssh-into-ec2-instance/003.png" />

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.

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/004.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=f22a007544c83ee88da771f990ce9b88" alt="" width="941" height="342" data-path="images/labs/support/ssh-into-ec2-instance/004.png" />

## 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**.**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/005.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=dfb6306ae68d53671d62d34b33b3e10a" alt="" width="774" height="324" data-path="images/labs/support/ssh-into-ec2-instance/005.png" />

\*\*3.\*\***Now you can see an example in below for SSH client key, copy the key we will use it later.**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/006.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=c1f419b0245de604dd0f33d6aecb86c7" alt="" width="777" height="380" data-path="images/labs/support/ssh-into-ec2-instance/006.png" />

**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>**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/007.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=3c8c8d42323c1c589c5a3dae2c03b417" alt="" width="777" height="336" data-path="images/labs/support/ssh-into-ec2-instance/007.png" />

**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**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/008.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=c5ae6942fe7c431d98f04c6ec237bf7a" alt="" width="777" height="257" data-path="images/labs/support/ssh-into-ec2-instance/008.png" />

**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](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.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/009.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=dec1f8ed6893f47c1f3dd991b1abc16d" alt="" width="602" height="589" data-path="images/labs/support/ssh-into-ec2-instance/009.png" />

* Click on the **Save Private Key** button.
* Enter *keypairname* and **Save**.
* **keypairname.ppk** file will be saved to your local machine.

3. Navigate to the EC2 instance page and get the public IP of the machine.
4. Open **Putty**

   * **Host Name : Enter the public IP address.**
   * <img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/010.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=2ad3bc5fdc3047ecbfac7424335e97f4" alt="" width="356" height="61" data-path="images/labs/support/ssh-into-ec2-instance/010.png" />
   * Click <img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/011.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=ebd9861d5f0abd6caeec42203ac2dafd" alt="" width="60" height="22" data-path="images/labs/support/ssh-into-ec2-instance/011.png" /> , select <img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/012.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=639b57e4b699b515b8c908ed49e9416f" alt="" width="67" height="21" data-path="images/labs/support/ssh-into-ec2-instance/012.png" />,and again click credentials, then <img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/013.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=f63629ee60bc5e45a57e5b41f3d249be" alt="" width="67" height="26" data-path="images/labs/support/ssh-into-ec2-instance/013.png" /> to select the private key (.ppk) that you converted from the .pem file.
   * Click on <img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/014.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=d85eb44a12199a364415e17b7b667727" alt="" width="87" height="26" data-path="images/labs/support/ssh-into-ec2-instance/014.png" />.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/015.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=d8fe0c91fb358ddb6051a9f32e9c1a7f" alt="" width="810" height="736" data-path="images/labs/support/ssh-into-ec2-instance/015.png" />

* Select **accept** to connect to the machine

<img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/016.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=001eb15361bddd05c1f74de63f115ef0" alt="" width="818" height="519" data-path="images/labs/support/ssh-into-ec2-instance/016.png" />

5. If you are using Amazon Linux AMI for the lab:

   * Enter user name: **ec2-user** and hit Enter.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/017.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=6186ef5da6d5a8b778b3b39a7ddbbd7c" alt="" width="368" height="96" data-path="images/labs/support/ssh-into-ec2-instance/017.png" />

6. If you are using Ubuntu AMI for the lab:

   * Enter user name: **ubuntu** and hit Enter.
7. If you are using OPENVPN AMI for the lab:

   * Enter user name: **root** and hit Enter.
8. You will see the console after a successful login.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/iAkc8cvYvGsOYFCQ/images/labs/support/ssh-into-ec2-instance/018.png?fit=max&auto=format&n=iAkc8cvYvGsOYFCQ&q=85&s=62e3083b8542fbc99c2d717af89e9a3c" alt="" width="614" height="316" data-path="images/labs/support/ssh-into-ec2-instance/018.png" />
