Disabling or enabling SSH root login
The Linux systems have a root account by default, which is enabled by default. If unauthorized users get SSH root access to the system, it is not a good idea because this will give an attacker complete access to the system.
We can disable or enable the root login for SSH as per our requirements to prevent the chances of an attacker getting access to the system.
Getting ready
We need two Linux systems to be used as a server and client. On the server system, install the package openssh-server
, as shown in the preceding recipe.
How to do it…
First, we will see how to disable SSH root login, and then we will also see how to enable it again:
- Firstly, open the main configuration file of SSH,
/etc/ssh/sshd_config
, in any editor.sudo nano /etc/ssh/sshd_config
- Now look for the line that reads as follows:
PermitRootLogin yes
- Change the value from
yes
tono
. Then, save and close the file:PermitRootLogin no
- The output obtained will be as follows:
- Once done, restart...