Setting root password for the first time and login as root in linux

sachin
edited July 2021 in Linux

If you are trying to login with root for the first time from user's account, you will need to set password first. In order to do that

sudo passwd root
# Enter password
# Re-enter password


Simply adding a password for root is not enough, you'll also need to edit `sshd_config`, and set PermitRootLogin from prohibit-password to yes:

vi etc/ssh/sshd_config

# Authentication:
LoginGraceTime 120
# PermitRootLogin prohibit-password
PermitRootLogin yes
StrictModes yes

Now restarting ssh service

systemctl restart sshd

and voilà it's done.

Tagged:
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!