To prevent the root user from being able to log in via the Secure Shell (SSH) service, you can follow these steps:
Open the sshd_config
file in a text editor. This file is typically located in the /etc/ssh
directory.
Find the PermitRootLogin
line in the file and set its value to no
. This will disable the ability of the root user to log in via SSH.
Save the file and exit the text editor.
Reload the SSH service to apply the changes. On most systems, you can use the following command to reload the SSH service:
systemctl reload ssh
Alternatively, you can restart the SSH service using the systemctl restart ssh
command.
After making these changes, the root user will no longer be able to log in to the system via SSH.
Note: Disabling the ability of the root user to log in via SSH can make it more difficult to manage the system remotely. It is recommended to create a separate user account for remote access and grant it the necessary permissions to perform administrative tasks.
For more information about managing the SSH service and configuring access to the system, you can refer to the documentation for your operating system or search online for tutorials and examples.