Search This Blog

Tuesday, 9 February 2021

Disable Root Account in Linux for users connecting via SSH

 Testing the user login before disabling root account

[osboxes@master ~]$ ssh root@databasehost

root@databasehost's password:

Last login: Sun Feb  7 01:56:55 2021

[root@databasehost ~]#


Disable root login

[root@databasehost ~]# cp /etc/ssh/sshd_config /etc/ssh/sshd_config_bak
[root@databasehost ~]# grep ^PermitRootLogin /etc/ssh/sshd_config
PermitRootLogin yes
[root@databasehost ~]# sed -i 's/PermitRootLogin yes/PermitRootLogin no/g' /etc/ssh/sshd_config
[root@databasehost ~]# grep ^PermitRootLogin /etc/ssh/sshd_config
PermitRootLogin no
[root@databasehost ~]# systemctl restart sshd


Test the ssh connection to root login to the remote system

[osboxes@master ~]$ ssh root@databasehost
root@databasehost's password:
Permission denied, please try again.
root@databasehost's password:

No comments: