paint-brush
How to Create an Amazon EC2 Instance With Remote Root User Access and Configuring an Usage Alertingby@rodrigokamada
New Story

How to Create an Amazon EC2 Instance With Remote Root User Access and Configuring an Usage Alerting

by Rodrigo KamadaJanuary 28th, 2025
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

An Amazon EC2 instance will be created using the Amazon Linux 2023 AMI operating system image. The root user will be configured to access the remote virtual server via SSH. A free tier usage alert will be set up for the instance.
featured image - How to Create an Amazon EC2 Instance With Remote Root User Access and Configuring an Usage Alerting
Rodrigo Kamada HackerNoon profile picture

Introduction

In this article, an Amazon EC2 (Elastic Compute Cloud) instance will be created using the Amazon Linux 2023 AMI operating system image, the root user will be configured to access the remote virtual server via SSH, and a free tier usage alert will be configured.

Prerequisites

Before you start, you need to install and configure the tools below to access the remote server.

  • AWS Account: Amazon Web Services is a cloud computing services platform, and it will be used to create the Amazon EC2 instance.


  • SSH Client: Secure Shell is a protocol for sending commands securely to a remote server, and it will be used to access the virtual server.


  • Terminal: Terminal is the visual interface where the user types commands and views results by interacting with the operating system programs.

Getting Started

Create the Instance on Amazon EC2

Amazon EC2 (Elastic Compute Cloud) is a scalable cloud infrastructure service that allows you to run virtual servers, select multiple operating systems and processor options, configure network security, and manage storage and memory. You can add or reduce resource capacity according to your business needs.


1. Let's access the AWS account. Access the site https://aws.amazon.com/ec2/, and click on the button Sign In to the Console.

2. Now, we will click on the button Sign in using root user email.

3. Next, we will click on the option Root user, fill in the field Email address, and click on the button Next.

4. Then, we will fill in the field Password, and click on the button Sign in.

5. After signing in, we will type ec2 in the search field, and click on the option EC2.

6. Now, we will click on the link Instances (running).

7. Next, we will click on the button Launch instances.

8. Then, we will fill in the field Name, select the option Amazon Linux 2023 AMI in the field Amazon Machine Image (AMI), and select the option Proceed without a key pair (Not recommended) in the field Key pair name - required and click on the button Launch instance.

9. Ready! The Amazon EC2 instance was created with the Amazon Linux 2023 AMI operating system.

Create the Root User Access

1. Let's create access for the root user. We will click on the menu Instances.

2. Now we will click on the link of the instance created.

3. Next, we will click on the tab Connect.

4. Then, we will click on the button EC2 Instance Connect.

5. After accessing the tab EC2 Instance Connect, we will click on the button Connect.

6. Now, we will type the command sudo -i to log in with the user root.

7. Next, we will type the command passwd to configure the root user password.

8. Then, we will add the remote access settings for the root user in the file /etc/ssh/sshd_config.

PermitRootLogin yes
PasswordAuthentication yes


9. After adding the remote access settings for the root user, we will type the command systemctl restart sshd to restart the SSH service.

10. Now, we will test the remote access with the root user. We will go to the page that contains the instance information and click on the icon to copy the public IP address.

11. Next, we will type the command ssh [email protected] using a public IP address to access the remote virtual server.

ssh [email protected]
The authenticity of host '3.80.139.206 (3.80.139.206)' can't be established.
ED25519 key fingerprint is SHA256:iQxE9Tn+UVDJGCQPe0ImkZ4W+/akI3VEiyHaHipPUXU.
This host key is known by the following other names/addresses:
    ~/.ssh/known_hosts:46: ec2-3-80-139-206.compute-1.amazonaws.com
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '3.80.139.206' (ED25519) to the list of known hosts.
[email protected]'s password: 

A newer release of "Amazon Linux" is available.
  Version 2023.6.20250123:
Run "/usr/bin/dnf check-release-update" for full release and version update info
   ,     #_
   ~\_  ####_        Amazon Linux 2023
  ~~  \_#####\
  ~~     \###|
  ~~       \#/ ___   https://aws.amazon.com/linux/amazon-linux-2023
   ~~       V~' '->
    ~~~         /
      ~~._.   _/
         _/ _/
       _/m/'
Last failed login: Sat Jan 25 14:30:25 UTC 2025 from 187.180.189.101 on ssh:notty
There were 82 failed login attempts since the last successful login.


12. Ready! The remote access to the root user was created and tested.

Create the Root User Access

The free tier usage alert helps you monitor your AWS service usage and cost by sending you email notifications when you exceed 100% of your free tier limit.


1. Let's create the free tier usage alert. We will click on the user menu, and click on the menu Billing and Cost Management.

2. Now, we will click on the menu Billing Preferences.

3. Next, we will click on the button Edit.

4. Then, we will click on the option Receive AWS Free Tier alerts, fill in the field Email address to receive Free Tier usage alerts - optional, and click on the button Update.

5. Ready! The free tier usage alert was created.

Conclusion

Summarizing what was covered in this article:

  • We created an Amazon EC2 instance using the Amazon Linux 2023 AMI operating system image.
  • We created the root user access to access the remote virtual server.
  • We created the free tier usage alert to monitor the usage and cost of AWS services.


You can use this article to create a virtual server, install and run a database, an HTTP server, or an application in a certain programming language.


Thank you for reading, and I hope you enjoyed the article!


This tutorial was posted on my blog in Portuguese.


To stay updated whenever I post new articles, follow me on Twitter and LinkedIn.