Quick Guide to Deploying a Linux EC2 Instance on AWS

Quick Guide to Deploying a Linux EC2 Instance on AWS

Amazon Web Services (AWS) is one of the top cloud services providers. You should be able to deploy a Linux machine on AWS after following this quick guide I have taken time to put together while documenting every step to achieving the final result.

If you are new to AWS, take your time to create an AWS account on aws.amazon.com. It is easy and straight forward. When you create the account, keep in mind that the email address and password you provide becomes the credentials for the root user. This root user has complete access to all AWS services and resources within that account.

For best practices, instead of using the root user for daily tasks, AWS recommends creating administrative users and roles using AWS Identity and Access Management (IAM). These users and roles can be granted specific permissions needed for their tasks, reducing the risk associated with using the highly privileged root user**
**It is crucial to secure the root user credentials to prevent unauthorized access. This includes using a strong password, enabling multi-factor authentication (MFA), and not creating access keys for the root user.

Now, you have created the AWS account and have granted specific permissions to the user, let’s proceed to creating an EC2 instance using the IAM user account.

  1. Type EC2 in the search button and select EC2 from the selection.

  1. Click Launch Instance.

  1. Give the Instance a name under Name and Tags.

  1. Select Amazon Linux as the AMI under Application and OS images

  1. For the Instance Type, we would select t2.micro since we are running on the free tier package.

  1. Under Key pair (login), click create new key pair.

  1. Give the key pair a name and select Create key pair.

  1. For the purpose of this blog, we would leave the Network settings, Configure storage and Advanced details in default state.

  2. Summary section shows us details of all the selections we have made in order to launch an EC2 instance.

    Select Launch Instance and wait for the initialization of the instance.

  1. Instance has successfully been initiated and launched.

  1. Under Resources, you can see how many instances you have and how many instance is running as indicated in the diagram below.

  1. Click the Instance ID of the new instance that is running.

  1. Select Connect to be able to connect the new instance.

  1. Under Connect to instance, you would see that the instance can be connected through four different ways.

    In this guide, I used two different ways to connect. I used the EC2 Instance Connect and SSH client.

    a. Click EC2 Instance Connect, leave all the other options as they are and select Connect.

  1. This opens in a new tab and connects.

  1. Another way is through the SSH client.

  1. Open the Command Prompt on Windows or Terminal on Mac and type the highlighted command and press Enter.

    By this time, you would be needing the path for the key pair that was downloaded earlier during the launch of the instance.

    You have to input the path for the key pair in the command to be able to connect just like I have done in the diagram.

From the command, let me breakdown the information for easy understanding.

ssh -i C:\Users\Downlaods\Shaffi_Key.pem ec2-user-107-21-187-179.compute-1.amazonaws..

Path or location of the key pair that was downloaded C:\Users\Downlaods\Shaffi_Key.pem

Username ec2-user

Public IP address 107-21-187-179

  1. Next you type Yes or Y when asked if you want to continue connecting.

  1. You get connected and welcomed to Linux.

  1. If you do not know how to find the key pair that was created, you can run the ls command on PowerShell and you would see the folder; Downloads folder.

  1. Run cd Downloads, followed by ls.

  1. The ls command would list all the files in the Downloads Folder and you would see the key pair.

  1. Finally, run the command ssh command and get connected to Linux.

I hope you find my post helpful, and it is able to guide you through the process with no difficulties.

Thank you.