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.
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
- If you don’t have an AWS account, you might want to open one right here
Once you are successfully signed up/logged in, you should see this on your screen.
2. We are going to search for EC2 instance on the search input
3. We should be seeing something similar to the image below. We are going to click on the launch instance.
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”.
5. Select an Amazon Machine Image (AMI). In this lab, we would be using, Amazon Linux 2 AMI.
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.
7. We will then create a Key Pair and give it a name.
This key pair allows us to securely connect to our instance. Make sure that the file is downloaded after creation.
8. We are going to leave the rest configuration as default and scroll down to launch our 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.
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.
- Select the instance and click on connect.
2. Click on the ssh client tab and copy the Example ssh -i “<keypair.pem>” ec2-user@<publicIpAddress>
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.
4. You will be asked if you are sure you want to continue connecting, reply with “yes” and enter.
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.