Overview
Lab details
- This lab walks you through the steps to launch and configure a virtual machine in the Amazon cloud.
- You will practice using Amazon Machine Images (AMI) to launch an Amazon EC2 Instance.
- You will use key pairs for SSH authentication to log into your instance.
- Duration: 30 minutes
- 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:- 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.
- 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.
- 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.
- 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).
- 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.
- 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

Task details
- Sign into AWS Management Console.
- Launch an Amazon Linux Instance from an Amazon Linux AMI 2023
- Find your instance in the AWS Management Console.
- SSH into your instance for Mac Users.
- SSH into your instance for Windows Users.
- Run a few other helpful commands.
- Validation of the lab
Launching the lab environment
- To launch the lab environment, Click on the Launch lab button.
- Please wait until the cloud environment is provisioned. It will take less than a minute to provision.
- Once the Lab is started, you will be provided with IAM user name, Password, Access Key, and Secret Access Key.
You can only start one lab at any given time
Lab guide
Lab steps
Task 1: Sign in to AWS Management Console
- Click on the Open console, and you will get redirected to AWS Console in a new browser tab.
- 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
- 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
- Make sure you are in the US East (N. Virginia) us-east-1 Region.
- Navigate to EC2 by clicking on the Services menu in the top, then click on EC2 in the Compute section.
- Navigate to Instances on the left panel and then click on the Launch Instance button.
- Enter Name as MyEC2Server.

- Choose an Amazon Machine Image (AMI): Select Amazon Linux 2023 kernel-6.1 AMI in the drop-down.
- Choose architecture as 64-bit(x86)

- Choose an Instance Type: Select t2.micro**.**

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

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

- 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

-
Inbound Security Group Rules,
- Choose Type: SSH
-
Source: Select Anywhere IPv4

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

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

Task 3: SSH into EC2 Instance
For MAC/Linux Users
- Open the terminal.
- Navigate to the location where your key pair is downloaded and stored on your local machine.
- To update Permissions, run the following command. Enter the keypair name at <keypair>

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

For Windows Users
- Download putty and puttygen from this link : https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
-
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.

- Click on Save Private Key.
- Enter keypairname and Save.
- keypairname.ppk file will be saved to your local machine.
- Navigate to the EC2 instance page and get the public IP of the machine.
-
Open Putty software.
- Host Name : Enter the public IP address

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

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

- If you are using Linux AMI other than Ubuntu for the lab:
- Enter user name: ec2-user and hit Enter.

- You will see the console after a successful login.

Task 4: Running Commands
- Switch to root user:
- Run updates using the following command:
- To find your current working directory, enter the command pwd
- 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
- Once the lab steps are completed, please click on the Check my work button on the Right side panel.
- This will validate the resources in the AWS account and shows you whether you have completed this lab successfully or not.
- Sample output :

Completion and conclusion
- You have successfully launched an EC2 Instance.
- You have logged into an EC2 instance as a MAC User.
- You have logged into an EC2 instance as Windows User.
- You ran a few other helpful commands.
End lab
- Sign out of the AWS Account.
- You have successfully completed the lab.
- 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.