Enabling root access via SSH (and when not to do it)
As we introduced in the previous section, there are some options that directly affect the access as root to the system, as shown in the following example:
PermitRootLogin PasswordAuthentication
Depending on your security requirements, there might be better options or combinations to use, so let’s discuss some scenarios.
It’s common to set some requirements such as not allowing root login, which can be set via PermitRootLogin no
in the sshd
configuration file (/etc/ssh/sshd_config
). This enforces that every user willing to become root will need to first SSH into the system with another user, and once connected, use su
or sudo
to switch to the root user.
Alternatively, you can use PermitRootLogin prohibit-password
, which will only allow connections to the system as root when using public key authentication (ahead in this chapter).
Probably, the worst case is to set PermitRootLogin yes
as this will allow...