Enable root login in Ubuntu server via ssh

Enable root login in Ubuntu server via ssh

Ubuntu servers comes with a security measurement which restricts you to use root after the server installation. However you can use root commands with sudo. But sometimes you may want to enable root login permanently.

This small guide will show you How to enable root login in ubuntu server via ssh

Step 1: Login to your server using your default user.

First we’ll set a password for root. To set a password for root, type the following command

sudo passwd root

This command will ask for your current user password then it will ask for the password you want to set for root.

2. Now we need to edit the ssh config file to allow root login.

sudo nano /etc/ssh/sshd_config

Add the following line to your sshd_config file and save(CTRL+O then CTRL+X).

PermitRootLogin yes

Enable root login in Ubuntu server via ssh


After saving that file, you need to restart your sshd service.

systemctl restart sshd
service sshd restart

That’s it. You can now login to your server as root via ssh.

When using SSH Keys, you can set the PermitRootLogin value to `without-password` instead of yes. To do this just modify the previous line with this.

PermitRootLogin without-password

Now you have the permission to login as root.


You may also like...

Notify of
Inline Feedbacks
View all comments