How to set root password for ubuntu servers

If you are having cloud instances, that provide you key files (pem/ppk) to login to your instances/servers, this post is suitable to you.

In this case, for security purposes, providers don’t allow users to login with root password but yet for some circumstances, if you want to set root password, follow below-mentioned steps.

1. Log into your instance/server through provided pem/ppk file.
2. fire below mentioned command

sudo su 

3. Change below-mentioned file with mentioned content

vi /etc/ssh/sshd_config

PermitRootLogin yes
PasswordAuthentication yes

4. save file and do

service ssh restart

5. now, let’s set root user’s password
6. First verify you are in root user

whoami         # if it's root
passwd         # it will ask you to type password, enter it 2 times and your password is setup.

Finally, try to login with root credentials and see if it works.
If you face any issues, feel free to comment below

Read our other blogs here

Drafted on: 1st April 2020

Article Name
How to set root password for ubuntu servers
This article focuses on how to set root password for your ubuntu servers/instances. If you are not able to login with password and/or using pem/ppk file to log in and wants to change the authentication method to password, this article is useful to you. This article can help you configure this on AWS EC2, Google Cloud instance, and many more such providers
Publisher Name

Leave a Comment