138

I just installed Ubuntu 14.04 on my server and I was setting up all my config files when I came across this in my sshd_config file:

# Authentication:
LoginGraceTime 120
PermitRootLogin without-password
StrictModes yes

This made me very worried. I thought that it was possible that someone could be logging into my server as root without a password.

I tried connecting to my server as root via:

johns-mbp:~ john$ ssh [email protected]
The authenticity of host '192.168.1.48 (192.168.1.48)' can't be established.
RSA key fingerprint is 40:7e:28:f1:a8:36:28:da:eb:6f:d2:d0:3f:4b:4b:fe.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.48' (RSA) to the list of known hosts.
[email protected]'s password:  

I entered a blank password and it didn't let me in, which was a relief. So my question is: what does without password mean and why is this a default in Ubuntu 14.04?

4 Answers 4

169

From the man page:

PermitRootLogin

Specifies whether root can log in using ssh(1). The argument must be “yes”, “without-password”, “forced-commands-only”, or "no”. The default is “yes”.

If this option is set to prohibit-password (or its deprecated alias, without-password), password and keyboard-interactive authentication are disabled for root.

If this option is set to “forced-commands-only”, root login with public key authentication will be allowed, but only if the command option has been specified (which may be useful for taking remote backups even if root login is normally not allowed). All other authentication methods are disabled for root.

If this option is set to “no”, root is not allowed to log in.

Thus, prohibit-password allows root login only with public key authentication. This is often used with shell scripts and automated tasks.

10
  • 2
    Not permitting 'Root login' using password is considered stronger security than allowing it. That said, you should not be logging into root at all, unless no other method (sudo, etc.) will work.
    – david6
    Apr 19, 2014 at 21:46
  • 5
    As you can see however, while the man page indicates the default is "yes", Ubuntu has made the default "without-password". Jun 9, 2014 at 21:37
  • 41
    So without-password means all methods allowed except password? It really sounds like "allowed to login without the need of a password".
    – Gauthier
    Sep 12, 2014 at 9:09
  • 1
    "All root access should be facilitated through a local logon with a unique and identifiable user ID and then via the su command once locally authenticated. Direct root login is extremely insecure and offers little in the way of audit trailing for accountability." - CIS IBM AIX Guide Sep 30, 2014 at 15:15
  • 34
    PermitRootLogin now accepts an argument of 'prohibit-password' as a less-ambiguous synonym of 'without-password'.
    – endolith
    Sep 16, 2016 at 0:57
18

Actually this setting does pretty much nothing if you are using PAM authentication. At the bottom of the sshd_config configuration file you will find:

# Set this to 'yes' to enable PAM authentication, account processing,
# and session processing. If this is enabled, PAM authentication will
# be allowed through the ChallengeResponseAuthentication and
# PasswordAuthentication.  Depending on your PAM configuration,
# PAM authentication via ChallengeResponseAuthentication may bypass
# the setting of "PermitRootLogin without-password".
# If you just want the PAM account and session checks to run without
# PAM authentication, then enable this but set PasswordAuthentication
# and ChallengeResponseAuthentication to 'no'.

The default setting on Ubuntu is to use PAM authentication:

UsePAM yes
2
  • 1
    In my brief experience, even setting this to no won't make PermitRootLogin without-password actually work, somehow! :(
    – cregox
    Dec 2, 2015 at 2:34
  • 1
    @cregox if you are using a typical desktop system, you need to do ssh-copy-id -i ~/.ssh/id_rsa.pub user@ip and it creates ~/.ssh/authorized_keys take in mind if you can't log in as root you wouldn't create this file in /root/.ssh/ but it works if you copy the file there
    – Rutrus
    May 6, 2016 at 1:46
6

In newer versions of sshd (OpenSSH 7.0 and above, released on 2015-08-11) "without-password" has been changed to "prohibit-password".

Both version work, probably best to use "prohibit-password" if you can: it explains itself better.

Source:

  • sshd_config(5): PermitRootLogin now accepts an argument of 'prohibit-password' as a less-ambiguous synonym of 'without-password'.
4

Note that there are legitimate reasons for logging in via root (but using cryptographic keys and never a password). A typical example is remotely syncing two servers (to have one of them being used as fail-over). Because the structure must be identical, often a root password is required.

Here is an example using unison for the synchronisation.

2
  • 2
    Won't logging in with a normal user (using cryptographic keys most likely) and having it belong to the sudo group allow you to do this as well?
    – dutoitns
    Mar 31, 2016 at 14:19
  • 1
    As far as I've tested it (that was back in 2015!), the answer is 'no' — it really didn't work. That might be a good reason why unison has been out of fashion lately (which is really a pity, since it continues to be developed), May 31, 2020 at 22:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .