How to Enable Root Login via SSH in Ubuntu

SSH on Ubuntu is by default organized in an exceedingly approach that disables the root users log in. Originally this is often enabled as a security measure which suggests that you simply cannot directly log in as the root user over SSH. However, you’ll simply use the Root SSH login via Sudo command. But, in some conditions, it’s a lot of convenient to directly logged in as root.

Following are the steps to enable Root login over SSH

1) Login to your server as root.

2) Now you are a root user. So, edit the sshd_config file located in /etc/ssh/sshd_config

vim /etc/ssh/sshd_config

3) Now, add the subsequent command to the file. Even though you’ll add it anyplace however we tend to advise you to follow the most effective observe by adding the command within the block for authentication.

PermitRootLogin yes

4) Save this file and exit.

5) Using the following command Restart your SSH server :

systemctl restart sshd

Or

service sshd restart

That’s it.

With this, the new line gets added and also the SSH server gets restart, this permits you currently to connect via the root user.

In this instance, you may be ready to log in because the root user by using either the password or an SSH key.

If you use SSH keys, you may be able to set the PermitRootLogin value to ‘without-password’ instead of yes. To complete this, simply modify step 2 with the subsequent command :

PermitRootLogin without-password

This method works on all versions of the Linux server on which the sshd service is installed. Just in case you’re using a cPanel server, still you’ll simply control this setting from the WHM interface. In such cases, we tend to suggest you to modify this setting from your control panel interface.