Saturday, 1 January 2022

How to Disable SSH Remote Root Login on CentOS 8



After fresh system installation the Remote root login is enabled by default on the CentOS 8. As recommended, SSH Remote root login must be disabled for security and compliance on production systems.
 
This article describes How to Disable SSH Remote Root Login on CentOS 8 System.
 
[root@linuxcnf ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
[root@linuxcnf ~]#
 
To disable remote SSH login for a root user on CentOS 8, need to configure SSH server. Follow the below steps to disable remote login for root user.
 
Step 1: Configure SSH Server: Run the following command to edit /etc/ssh/sshd_config and change the following line from PermitRootLogin yes to PermitRootLogin no Uncomment the PermitRootLogin line if already commented.
 
[root@linuxcnf ~]# vi /etc/ssh/sshd_config
……………………..
PermitRootLogin no
……………………..
[root@linuxcnf ~]#
 
Step 2: Restart SSH Service: Once changes have made, run the following command to restart SSH service:
 
[root@linuxcnf ~]# systemctl restart sshd
[root@linuxcnf ~]#
 
Step 3. Validate Login Status: Now try to login with root user from remote machine/client:
 
[root@linuxcnf ~]# ssh 192.168.1.105
root@192.168.1.105's password:
Permission denied, please try again.
root@192.168.1.105's password:
 
[root@linuxcnf ~]#
 
Done!!! After the changes now SSH Remote Root Login Disabled.

No comments:

Post a Comment