Abdullah Jimoh
4 min readSep 1, 2022

--

HOW TO LAUNCH AND CONNECT TO AWS EC2 INSTANCE VIA SSH

We will be learning how to launch an EC2 Instance on the Amazon Web Service console and connect to it on our terminal using SSH.

We will break these terminologies into sub-sections before stepping right into the labs.

Amazon EC2 Insance

What is Amazon Web Service (AWS)?

AWS provides an on-demand cloud-computing platform to individuals and companies on a pay-as-you-go basis.

What is EC2?

Elastic Compute Service (EC2) is a foundational piece of the AWS cloud computing platform and is a service that provides servers for rent in the cloud. Users can manage and deploy an application to it, and these servers are called instances.

What are Instances?

Instances are physical servers in a data center.

Now that we have learned the basic terminologies and why we need EC2 instances, let’s get right to launching one.

HOW TO LAUNCH AN EC2 INSTANCE

Prerequisites:

AWS account

Ubuntu on Windows or A MacBook

  1. If you don’t have an AWS account, you might want to open one right here
sign up/sign in

Once you are successfully signed up/logged in, you should see this on your screen.

AWS console

2. We are going to search for EC2 instance on the search input

Search Box

3. We should be seeing something similar to the image below. We are going to click on the launch instance.

EC2 Dashboard

4. When launching an EC2 instance we need to give it a unique name that serves as an identity among other instances in our account. I will name this; “mySampleWebServer”.

EC2 Launch Form

5. Select an Amazon Machine Image (AMI). In this lab, we would be using, Amazon Linux 2 AMI.

Selecting AWS Linux Image

An Amazon Machine Image (AMI) is a supported and maintained image provided by AWS that provides the information required to launch an instance… read more.

6. We will specify an instance type and we are selecting t2.micro that is free eligible.

Selecting instance type

7. We will then create a Key Pair and give it a name.

Creating Key Pair

This key pair allows us to securely connect to our instance. Make sure that the file is downloaded after creation.

Form to finish creation of keypair

8. We are going to leave the rest configuration as default and scroll down to launch our instance.

Launching an Instance

9. We should have the newly launched instance on our instance table. It will take a couple of seconds or minutes, but we will ensure the instance state is running and the instance status check is passed.

The instance is successfully launched

CONNECTING TO OUR EC2 INSTANCE

Now that we have successfully launched an EC2 to the cloud let us connect via ssh using the keypair that we created.

  1. Select the instance and click on connect.
Connecting to an EC2 instance.

2. Click on the ssh client tab and copy the Example ssh -i “<keypair.pem>” ec2-user@<publicIpAddress>

Connect command

3. Open your Ubuntu virtual machine on your Windows or Mac terminal. Ensure you are in the directory where your key pair file is located. Then paste the text you copied.

Ubuntu Virtual machine

4. You will be asked if you are sure you want to continue connecting, reply with “yes” and enter.

Successfully connected to an EC2 instance.

NOTE: In a situation when you run into an error about permission. Run chmod 600 <keypairname.pem> before you connect

Congratulations, you just connected to your EC2 instance via SSH!!!

Conclusion

Thank you for following along with this lab and I hope you have a better understanding of launching an EC2 on the AWS cloud and connecting via SSH.

If you have any questions, I will be in the comment section.

--

--

Abdullah Jimoh

Software Engineer | DevOps Engineer | Technical Writer