Ubuntu – Trying to ssh root, why get permssion denied in 16.04

16.04permissionsrootssh

I'm trying to set up passwordless ssh between root accounts in 16.04 (needed for Hadoop installs).
I set up a password for root by sudo su - root and passwd.

When I try e.g.

ssh -l root slave3 or ssh-copy-id -i $HOME/.ssh/id_rsa_root.pub root@master

I get

Permission denied, please try again.

I have tried all the advice I can find i.e. making the following edits (one at a time) to /etc/ssh/sshd_config:

PermitRootLogin without-password 
PermitRootLogin yes 
RSAAuthentication yes
PubkeyAuthentication yes
#StrictModes yes
UsePAM no
AllowUsers root hduser

Followed by sudo service ssh reload after each, but still I get permission denied. Any help is much appreciated.

Best Answer

In Ubuntu, the default SSH policy is "Deny root login via SSH directly, except by SSH Key Authentication only." This is done by the PermitRootLogin without-password line of /etc/ssh/sshd_config.

You can enable root password login over SSH by changing that line to say PermitRootLogin yes. However I must caution you - this permits brute forcing attempts over the Internet of the root password which puts your server at risk - you may wish to consider blocking all SSH traffic except from known "good IP sources" of which you trust the source IPs in order to reduce the chance of being brute-forced on the root login. Where this is not possible, you should strongly consider setting up SSH key authentication for the root account instead of password authentication.

Related Question