How to Enable SSH Root Login on Ubuntu 16.04

Enable SSH Root Login

As what we wrote in the previous article on how to allow SSH root on Ubuntu 14.04, after installing a fresh new copy of Ubuntu 16.04 LTS, we find that once again (for better security) ssh root access has been configured to “prohibit-password” by default. This prevents root login via SSH.

Before you begin the following steps, make sure you first enabled root password. By default in Ubuntu root password is empty, so it can not be accessed remotely via SSH.

You would have to change the empty root password to login directly. Personally, I strongly suggest you login to root through your sudo account with sudo -i.

The following steps will explain how to Enable SSH Root Login on Ubuntu 16.04.

1. How to enable root password ?

ehowstuff@ubuntu16:~$ sudo passwd root
Enter new UNIX password:
Retype new UNIX password:
passwd: password updated successfully

2. How to Enable SSH Root Login on Ubuntu 16.04 (sshd_config -> change permitrootlogin to yes)

Open sshd config file :

# vi /etc/ssh/sshd_config

Enable SSH Root Login
Comment out and add the following line :

..
# Authentication:
LoginGraceTime 120
PermitRootLogin prohibit-password
StrictModes yes
..
Enable SSH Root Login
..
# Authentication:
LoginGraceTime 120
#PermitRootLogin prohibit-password
PermitRootLogin yes
StrictModes yes
..

3. Finally, apply the changes by restart or reload sshd service :

# systemctl restart sshd

Source