Allow root SSH on Ubuntu 16.04

Note: It is assumed that you have already enabled the root account using the following command: sudo passwd root
As was the case in our previous article Allow root SSH on Ubuntu 14.04, after installing a fresh new copy of Ubuntu 16.04 LTS, we found that once again (for better security) root ssh access was set to without-password by default . What that means to you is that if you are trying to ssh to your server with your root account and password, you will receive an access denied error. In order to overcome this limitation, you will need to edit the file /etc/ssh/sshd_config to allow root password logins through ssh. As shown below, comment out #PermitRootLogin without-password and add PermitRootLogin yes.

Once the file is saved, you will need to restart the ssh daemon in order for the changes to take affect using the command below.

After the ssh service is restarted, you should now be able to login through ssh using your root account and password.

Did you find this article useful? Why not share it with your friends?

10 thoughts on “Allow root SSH on Ubuntu 16.04

  1. After modifying the sshd_config and restaring the ssh service you have to change the root password. So, sudo -i, and once logged as root change the password with passwd

    root@ubuntu:~# passwd
    Enter new UNIX password:
    Retype new UNIX password:
    passwd: password updated successfully

    After this you should be able to connect with ssh with root directly.

  2. Hello, I think I found out why someone is saying that this solution is not working: if your root account hasn’t got a password (and by default in Ubuntu root password is empty), when you try to connect it says “permission denied”.
    I did solve the problem loggin in (locally) as normal user, then sudo passwd root. Typed my password and then choosen root password twice. After that root ssh worked fine.
    Hope this helps.
    Cheers, Alessandro

    1. Good point Alessandro, the root account is disabled by default. The article assumes that the root account has already been enabled.

  3. It works 100%. This is exactly how you do it, hundreds of sites say the exact same thing

    There is a ssh_config in there too, maybe you are editing that instead. One thing is certain, you’re doing it wrong.

    1. Despite what hundreds of sites say, and being absolutely certain I am editing the correct file, and having two identical brand new PC’s, and reinstalling Ubuntu 16.04 twice, I get the same result on both machines. There is something missing from these instructions because as Hendrik Kluever said, “It DOES NOT WORK.”

      1. Rusty, as you can see in Hendrik’s comment below, clearly he was editing the wrong file – ssh_config. If you could provide some more information other than “It DOES NOT WORK” we can probably help you out.

    1. That is because as the article says, edit the sshd_config file. Try that and let me know how that works out for you.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.