Set up an Amazon Elastic Compute Cloud Linux Instance

Setup an Amazon Elastic Compute Cloud Linux Instance
This tutorial focuses on setting up and terminating an Amazon Elastic Compute Cloud (Amazon EC2) Linux instance in AWS.


Amazon Elastic Compute Cloud (EC2) offers scalable computing capacity for AWS Cloud users. Amazon EC2 eliminates the need to invest in hardware up front to deploy and develop applications faster. Users can use Amazon EC2 to launch, configure, and manage virtual servers, security networking, and storage. Amazon Elastic Compute Cloud also offers virtual computing environments, known as instances, for its users. Amazon EC2 enables users to scale down or up instances to handle changes in requirements or spikes in popularity, reducing the need to forecast traffic.


Get Started with Amazon EC2 Linux Instance

Set up to Use Amazon EC2

Before launching a Linux instance in Amazon EC2 for the first time, the user must complete the following tasks:

  • Sign up for AWS
  • Create a Key Pair 
  • Create a Security Group 


Sign up for AWS

When a user signs up for Amazon Web Services, their account is automatically signed up for all the services in AWS, including Amazon Elastic Compute Cloud, and they are charged only for the services they use.

With Amazon EC2, users only need to pay for what they use, and if they are new to AWS, they can get started with Amazon EC2 for free. If you already have an AWS account, skip to the next task. If not, follow the below steps to create an AWS account.

  • Open a web browser and go to the AWS Sign-up page
  • Follow the detailed online instruction.
  • Note that part of the sign-up procedure involves getting a phone call and entering the verification code on the phone keypad.


Create a Key Pair 

Amazon Web Services uses public-key cryptography to secure the login information for the instances. To create a key pair, follow the below steps:

  • Open the Amazon Web console, go to the EC2 section, or use the following URL
  • Choose Key Pairs in the navigation panel.
  • Next, click Create key pair and fill the following details in their respective section.

        – Name: Mention a descriptive name for the key pair. Amazon Elastic Compute Cloud associates the public key with the name that the user specified in this section. The name of the key pair can include up to 255 ASCII characters without any leading or trailing spaces.

        – File Format: In this section, choose the format in which the user should save the private key. To use the private key with OpenSSH, choose the format of the file as pem. If the key needs to be used with PuTTY, then choose ppk.

  • After filling in the details, click the Create key pair button.
  • The private key file gets automatically downloaded by the browser. The file name is the name that the user specified as their key pair name, and the extension is determined by the format that the user has chosen in the previous step. 
  • Finally, save the downloaded private key file into a safe folder.

          > Note: Users can’t save the private key file later, so make sure to save the key.

  •  If the user uses an SSH client on a Linux system or macOS to connect to the creating Linux instance, execute the following command to set read-only permissions for the private key file. In the below command, replace the key-pair-name part with the actual key pair file name.
$ chmod 400 key-pair-name.pem


  • If the user has not set these permissions, then the user can’t connect to the instance using this key pair. 


Create a Security Group 

To create a security group with the least privilege, follow the below steps: 

  • Open the Amazon EC2 console and select a Region for the security group from the navigation bar. Security groups are specific to a region, so the user should select the same region in which they created the key pair.
  • Go to Security Groups and click Create security group.
  • Fill in the following details:

          a) Enter a name and description for the new security group. Always make sure to enter a name that is easy to remember, followed by _SG_, plus the Region name. For eample: test_SG_uswest2.

          b) Select the default VPC for the Region from the VPC list.

          c) In the Inbound rules section, add rules that allow specific traffic to the instance. 

          d) To allow all outbound traffic, keep the default rule in the Outbound rules section.

  •  After filling in the details, click the Create security group button.


Launch a Linux Instance

To launch a Linux instance, follow the below steps:

  • Open the Amazon EC2 console, and from the console dashboard, select Launch Instance.
  • The Choose an Amazon Machine Image (AMI) page shows a list of Amazon Machine Images (AMIs) that serve as templates for the user instance. From the list, choose the HVM version of Amazon Linux 2 to launch a Linux instance. 
  • Next, select the hardware configuration of the instance from the Choose an Instance Type page. By default, the t2.micro instance type is selected. 
  • After selecting the instance type, click the Review and Launch button to let the wizard complete the other configuration settings for the user.
  • Click Next to go to the Review Instance Launch page.
  • Under the Security Groups section, customers can see that the wizard has created and selected a security group for the user. Customers can use this security group or select the security group they have created in the previous steps. Follow the below steps to choose the created security group:

          1. Go to the Edit security groups section.

          2. On the Configure Security Group page, make sure that the Select an existing security group option is enabled.

          3. Select the security group from the existing security groups drop-down and then select Review and Launch.

  •  After selecting the security group, click Next to go to the Review Instance Launch page and click Launch.
  • When the system prompts for a key pair, select the Choose an existing key pair option and select the key pair you created before from the list.

        > Note: Don’t select the Proceed without a key pair option as the user can’t connect to the instance later.

  •  Finally, select the acknowledgment check box and then click the Launch Instances button. 
  • Users can view the status of the launch from the Instances screen. A confirmation page will notify that the instance is launching. Select View Instances to close the confirmation page and return to the console.
  • After the instance starts, the instance’s state changes to running and receives a public DNS name. (If the Public IPv4 DNS detail is hidden, click on the Settings icon in the top-right corner, toggle on Public IPv4 DNS, and click Confirm).
  • Customers can go to the Status check column to check the current status of the instance.


Terminate an Instance

To terminate an EC2 instance, follow the below steps:

  • Login to Amazon Management Console and choose Instances from the navigation panel. 
  • Select the instance that you want to terminate from the list of instances.
  • Choose Instance state >> Terminate instance.
  • Click Terminate when prompted for confirmation.



This tutorial presents the process to set up and terminate an Amazon EC2 Linux instance in AWS. Hope this tutorial was helpful, and do reach out to us if you have any query or suggestions.


Share this post

Services to Explore

Stay up to date!

Stay up to date with the Web Hosting, Cloud and Server Management Industry News and Tutorials!

We will send you only the relevant emails, and we respect your privacy. Please review our privacy policy for more info.

Managed AWS Services

Focus on your business, and let us take care of your AWS Cloud Infrastructure!
From what you are reading, it seems you are interested in AWS Cloud and related technologies. If you have a moment to spare, please take a look at our Managed AWS Services, which might interest you even more!
Managed AWS Cloud

Value-Added Services

We have services that can help you run a successful business. With us, you don't have to worry about these areas because our experts will take care of it for you.

ServerHealers uses cookies.