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

# Launching EC2 Machine and SSH using Putty

> Hands-on lab · 30m

Launch this lab in the IP Lab Portal, then follow the steps below in the AWS console.

<a className="ip-lab-portal-btn" href="https://labs.intellectualpoint.com/labs/launching-ec2-machine-and-ssh-using-putty" target="_blank" rel="noreferrer">
  Open IP Lab Portal
</a>

## Overview

### Lab details

1. This lab walks you through the steps to launch and configure a virtual machine in the Amazon cloud.
2. You will practice using Amazon Machine Images (AMI) to launch an Amazon EC2 Instance.
3. You will use key pairs for SSH authentication to log into your instance.
4. Duration: **30 minutes**
5. AWS Region: **US East (N. Virginia) us-east-1**

### Introduction

#### What is the importance of SSH in EC2 Instance ?

SSH (Secure Shell) is essential for connecting to an EC2 (Elastic Compute Cloud) instance because it provides a secure method for accessing and managing your EC2 instance remotely. Here are some reasons why SSH is necessary for EC2 instances:

1. Remote Access: SSH allows you to remotely connect to your EC2 instance over a secure channel. You can execute commands, manage files, and perform administrative tasks on the EC2 instance from your local machine.
2. Secure Communication: SSH provides encryption and authentication mechanisms, ensuring that the data transmitted between your local machine and the EC2 instance is secure. It protects against eavesdropping, data tampering, and unauthorized access.
3. Administrative Tasks: SSH enables you to perform various administrative tasks on the EC2 instance, such as installing software, configuring settings, managing user accounts, and troubleshooting issues.
4. File Transfer: SSH includes secure file transfer capabilities, allowing you to securely transfer files between your local machine and the EC2 instance using tools like SCP (Secure Copy) or SFTP (SSH File Transfer Protocol).
5. Command Execution: With SSH, you can execute remote commands on the EC2 instance. This is particularly useful for running scripts or automating tasks on the EC2 instance without the need for direct physical access.
6. Access Control: SSH provides access control mechanisms, such as using SSH keys or passwords, to authenticate and authorize users who connect to the EC2 instance. This helps ensure that only authorized individuals can access the instance.

### Architecture diagram

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/001.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=2c748cfd6ded1e58d27de0d6d08eeb9f" alt="" width="1100" height="1280" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/001.png" />

### Task details

1. Sign into AWS Management Console.
2. Launch an Amazon Linux Instance from an Amazon Linux AMI 2023
3. Find your instance in the AWS Management Console.
4. SSH into your instance for Mac Users.
5. SSH into your instance for Windows Users.
6. Run a few other helpful commands.
7. Validation of the lab

### Launching the lab environment

1. To launch the lab environment, Click on the **Launch lab** button.

2. Please wait until the cloud environment is provisioned. It will take less than a minute to provision.

3. Once the Lab is started, you will be provided with **IAM user name**, **Password**, **Access** **Key**, and **Secret** **Access** **Key**.

<Note>
  You can only start one lab at any given time
</Note>

## Lab guide

### Lab steps

#### Task 1: Sign in to AWS Management Console

1. Click on the **Open console**, and you will get redirected to AWS Console in a new browser tab.
2. On the AWS sign-in page,

* Leave the Account ID as default. Never edit/remove the 12-digit Account ID present in the AWS Console. otherwise, you cannot proceed with the lab.
* Now copy your **User Name** and **Password** in the Lab Console to the **IAM Username and Password** in AWS Console and click on the **Sign in** button

3. Once Signed In to the AWS Management Console, Make the default AWS Region as **US East (N. Virginia) us-east-1.**

#### Task 2: Launching an EC2 Instance

1. Make sure you are in the **US East (N. Virginia) us-east-1 Region**.
2. Navigate to **EC2** by clicking on the **Services** menu in the top, then click on **EC2** in the **Compute** section.
3. Navigate to **Instances** on the left panel and then click on the **Launch Instance** button.
4. Enter **Name** as ***MyEC2Server.***

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/002.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=7cbe12a89224dfda6e3812d7f286ead3" alt="" width="975" height="190" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/002.png" />

5. Choose an Amazon Machine Image (AMI): Select **Amazon Linux 2023 kernel-6.1 AMI** in the drop-down.

* Choose **architecture** as **64-bit(x86)**

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/003.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=21007fdf2b8a531256f214a744d37be3" alt="" width="1222" height="796" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/003.png" />

6. Choose an **Instance Type**: Select ***t2.micro***\*\*.\*\*

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/004.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=bd1aee684274c54f8ba2231158faceb5" alt="" width="1166" height="262" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/004.png" />

7. For creating new key pair click on the link Create new key pair.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/005.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=13905302303d438ec5221d9030e1ff98" alt="" width="1165" height="186" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/005.png" />

8. Give it a name **SSHkey**. and select **.pem for mac os** and **.ppk for Windows.** as per your system, Click on **Create Key pair** button.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/006.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=cb9cbacc2b05a88c103d2736516e399a" alt="" width="745" height="679" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/006.png" />

9. In Network Settings Click on **Edit** Button:

* Auto-assign public IP: **Enable**
* Select **Create new Security group**
* Security group name : Enter ***MyEC2Server\_SG***
* Description : Enter ***Security Group to allow traffic to EC2***

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/007.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=9fa940861de52ce4815d4f76166b429e" alt="" width="1171" height="431" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/007.png" />

* Inbound Security Group Rules,

  1. Choose Type: **SSH**
  2. Source: Select **Anywhere IPv4**

     <img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/008.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=1de9a469604c4e57c169ba229ac6ce9c" alt="" width="1190" height="322" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/008.png" />

10. **Launch Status:** Your instance is now launching. Click on **View Instances**. In the dashboard find your instance and wait for complete initialization of the instance until the instance state changes to running.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/009.jpg?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=3cb6d8236cd7dc459365dcb3b70ec897" alt="" width="1013" height="108" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/009.jpg" />

11. Note the IPv4 Public IP Address of the EC2 instance. A sample is shown in the screenshot below.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/010.jpg?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=cebdd61080c9a588d5f031e171c1bbd6" alt="" width="956" height="230" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/010.jpg" />

#### Task 3: SSH into EC2 Instance

###### For MAC/Linux Users

1. Open the terminal.
2. Navigate to the location where your **key pair** is downloaded and stored on your local machine.
3. To update **Permissions**, run the following command. Enter the keypair name at \<keypair>

chmod 400 \<keypair>

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/011.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=a9d93944bbb6ad01d57dc61195b374bf" alt="" width="442" height="90" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/011.png" />

4. To SSH and connect to the EC2 Instance, enter the following command:

   * Syntax: **ssh -i keypair ec2-user\@publicIPAddress** (enter the public address you saved earlier)
   * Sample: **ssh -i keypair ec2-user\@107.21.198.65**
   * Up next, type **yes** and then hit **enter.** You will be successfully logged on to the EC2 Instance.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/012.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=1bf4690be57bbc86b7c55b9ec83ff80c" alt="" width="585" height="261" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/012.png" />

##### For Windows Users

1. Download putty and puttygen from this link : [https://www.chiark.greenend.org.uk/\~sgtatham/putty/latest.html](https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html)
2. To convert your key pair .pem to .ppk:

   > **Note: If you've download the keypair file in .ppk format you can ignore the conversion part and proceed with 4th point.**

   * Open **Puttygen** from your computer.
   * Click on **Load**.
   * Click on **All files** to show your .pem file and select the **.pem file**.
   * You will get a success message if done correctly.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/013.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=e8ac775c5e38c65e7d5513f0e74d1a03" alt="" width="478" height="466" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/013.png" />

* Click on **Save Private Key**.
* 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 software.**

   * Host Name  : Enter the public IP address

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/014.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=a8fb9a2c89b770031ae02502ccbafdd5" alt="" width="284" height="47" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/014.png" />

* Click **SSH** , select **Auth** and again click credentials, then **Browse** to select the private key (.ppk) file.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/015.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=64c22b239f056f311de541db1f82f2c1" alt="" width="597" height="541" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/015.png" />

* Click on **Open**.
* Select **Yes** to connect to the machine.

  <img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/016.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=72162aff3dd9b32925a6fd84739535ec" alt="" width="515" height="376" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/016.png" />

5. If you are using Linux AMI other than Ubuntu for the lab:

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

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/017.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=acf90f83755ae62d264e06ecb19fbcdf" alt="" width="286" height="73" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/017.png" />

**Note :** If you are using Ubuntu AMI for the lab then : Enter username: ***ubuntu*** and hit Enter.

6. You will see the console after a successful login.

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/018.png?fit=max&auto=format&n=sjxZZnuQfFzzjiqS&q=85&s=6aae758dff5117f163199e0b4d53171a" alt="" width="485" height="252" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/018.png" />

#### Task 4: Running Commands

1. Switch to root user:

sudo su

1. Run updates using the following command:

yum -y update

1. To find your current working directory, enter the command **pwd**
2. Enter the **exit** command then again **exit** to log out of Putty.

> #### Do you know?
>
> *SSH is known as Secure shell. SSH offers greater flexibility, customization options, and compatibility with existing workflows. On the other hand, Instance Connect simplifies key management, enhances security, and provides an easy-to-use web-based interface for connecting to instances.*

#### Task 5: Validation Test

1. Once the lab steps are completed, please click on the **Check my work** button on the Right side panel.
2. This will validate the resources in the AWS account and shows you whether you have completed this lab successfully or not.
3. Sample output :

<img src="https://mintcdn.com/ip-cloud-architect-pathway/sjxZZnuQfFzzjiqS/images/labs/launching-ec2-machine-and-ssh-using-putty/019.gif?s=5861cec41d35dca163792d8c6fb2210e" alt="" width="1000" height="440" data-path="images/labs/launching-ec2-machine-and-ssh-using-putty/019.gif" />

### Completion and conclusion

1. You have successfully launched an EC2 Instance.
2. You have logged into an EC2 instance as a MAC User.
3. You have logged into an EC2 instance as Windows User.
4. You ran a few other helpful commands.

### End lab

1. Sign out of the AWS Account.
2. You have successfully completed the lab.
3. Once you have completed the steps, click on **End lab** in the IP Lab Portal.

## What gets checked

When you press **Check my work**, the platform verifies each of these:

* **Launch an EC2 Instance** — Check whether an EC2 Instance is launched or not.

## Related help

* [FAQs and Troubleshooting](/aws-cp/support/faqs-and-troubleshooting)
