Create a Linux Server on AWS EC2

by

Creating an EC2 Linux Server

In this chapter, you will learn how to:

  • Create your first EC2 Linux server
  • Connect to the Linux instance

Steps to Create an EC2 Linux Server

1. Log in to the AWS Management Console

Use the following link to log in:

AWS Management Console

2. Navigate to EC2

After signing in, use the search bar at the top to search for EC2.
Click on EC2 from the search results.

EC2 Search

Once inside the EC2 Dashboard, click on Instances.

EC2 Dashboard

3. Launch an EC2 Linux Server

Click on the Launch Instance button.

Launch Instance

3.1 Configuring the Instance

  • Instance Name: Enter any name of your choice.
  • Amazon Machine Image (AMI): For simplicity, choose Amazon Linux, which is a distro provided by AWS.
  • Instance Type:
    • Choose t3.micro, which costs $0.024 per hour while running.
    • This is an On-Demand Instance, meaning you are charged only when it's running.
    • When you no longer need it, you can stop the instance to avoid charges.

Instance Type

  • Key Pair: Use the key pair you created in the last chapter or create a new one.
    • This key pair is very important, so keep it safe and secure.

Key Pair

  • Network Settings: Keep everything as default.

Network Settings

  • Storage: Set it to 8GB.

Storage

4. Launch the Instance

After completing the configurations, click on the Launch Instance button.


5. Checking the Instance

Once the instance is launched, go back to the AWS Console. You will see that your instance has been created.
Locate the Public IPv4 address, as we will use it to connect to the instance.

Instance Created


6. Connect to the Instance

Since the instance runs Linux, we will use SSH (Secure Shell) to securely connect to it.
This connection happens over port 22, so keep this in mind as we will discuss security groups in later chapters.

How to Connect to an EC2 Linux Instance Using SSH

Step 1: Locate Your Key Pair

When you launched your EC2 instance, you created or selected an SSH key pair (.pem file).
This file is required to authenticate your connection.

Step 2: Find the Public IP Address of Your Instance

  1. Go to the AWS EC2 Dashboard.
  2. Click on Instances.
  3. Locate your instance and copy the Public IPv4 address.

Step 3: Connect Using SSH

Use the following command from your local machine (Mac, Linux, or Windows using WSL/Git Bash):

ssh -i /path/to/your-key.pem ec2-user@your-instance-ip

Example: In my case, the command would be:

ssh -i /Users/tungnguyen/development/dalabs-server.pem ec2-user@3.106.218.201

image
So You are able to login to the linux server now, you can do a lot of things with this server like install apps for this, make this one as a vpn or deploy your application to this. In up coming chapters, we will have more deep down details about this. You Are Now Logged Into Your Linux Server! Now that you have successfully connected, you can start using your EC2 instance. Some possibilities include:

  • Installing applications
  • Setting up a VPN
  • Deploying an application

In the upcoming chapters, we will explore more advanced configurations and security settings