Saturday, 1 January 2022

How to Enable SSH root login on CentOS Stream 9 System



After fresh system installation the root login on the CentOS Stream 9 is disabled by default. When attempt to login as root user to CentOS Stream 9 the access will be denied (access denied).
 
login as: root
root@192.168.1.151's password:
Access denied
root@192.168.1.151's password:
 
This article describes How to Enable SSH root login on CentOS Stream 9 System.
 
[root@LinuxCNF ~]# cat /etc/redhat-release
CentOS Stream release 9
[root@LinuxCNF ~]#

To enable remote SSH login for a root user on CentOS Steam 9, need to configure SSH server. Follow the below steps to allow remote login for root user. But this is not recommended on/for production server.
 
Step 1: Configure SSH Server: Run the following command to edit /etc/ssh/sshd_config and change the following line from PermitRootLogin prohibit-password to PermitRootLogin yes
 
[root@LinuxCNF ~]# vi /etc/ssh/sshd_config
……………………….
PermitRootLogin yes
……………………….
[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:
 
login as: root
root@192.168.1.151's password:
Last failed login: Sat Jan  1 18:01:21 IST 2022 from 192.168.1.102 on ssh:notty
There were 2 failed login attempts since the last successful login.
Last login: Sat Jan  1 17:55:32 2022 from 192.168.1.102
[root@LinuxCNF ~]#
 
Done!!! After the changes now login successful with 2 failed login attempts.

No comments:

Post a Comment