DevOps

How to Enable root User Login in EC2


Spring Datafication 2023. 3. 2. 22:03

Cautions

For security reasons, you should not use the root user for day-to-day activities. Instead, create an IAM user and use that user to perform administrative tasks.
Root user login is disabled by default in Amazon Linux 2 AMI. You can enable root user login by following the steps below.

ON EC2 INSTANCE-AMI LINUX 2

If we have an EC2 instance with Amazon Linux 2 AMI, we can enable root user login by following the steps below.
**

**
Commonly, the ec2-user is the default user in Amazon Linux 2 AMI. We can check this by running the following command.****

$ whoami

and also we can verify details of our instance OS by running the following command.

$ cat /etc/os-release

The ec2-user might have fewer privileges than the root user. So, we need to enable root user login to perform administrative tasks.

It might be more reasonable to create an IAM user and use that user to perform administrative tasks by giving the user enough privileges.

The goal of this article is to enable root user login in Amazon Linux 2 AMI.


Enable root user login in Amazon Linux 2 AMI

The ec2-user cannot do this changes by default. So, we need to switch to the root user to perform this task.
Which implies we need to login as root user in the web-browser console from aws.

  1. Click Connect from the instance details page.
  2. Change the username to root.

3. From the console, we want to edit the sshd_config file to enable root user login.

  1. We uncomment the PermitRootLogin yes. Save the file and exit(:wq!).
  2. We want to edit the authorized_keys file .
    In this file we want to clear all text before the ssh-rsa. Save the file and exit(:wq!).
  3. We would want to exit the try login as root user.


Conclusion

We have enabled root user login in Amazon Linux 2 AMI. We can login as root user from any ssh client.
This is not recommended for security reasons. Instead, we should create an IAM user and use that user to perform administrative tasks.


References

MICROFOCUS
StackExchange
StackExchange

반응형

'DevOps' 카테고리의 다른 글

onlyoffice for alfresco 7.2.X | 7.3.X  (0) 2023.01.09
What is API Gateway Throttling  (0) 2022.09.28
Dockerfile  (0) 2022.05.24
Docker Process & Volumes  (0) 2022.05.23
Docker  (0) 2022.05.23