To disable root login, open the main ssh configuration file /etc/ssh/sshd_config with your choice of editor.
# vi /etc/ssh/sshd_config
Search for the following line in the file.
#PermitRootLogin no
Remove the ‘#‘ from the beginning of the line. Make the line look similar to this.
PermitRootLogin no
Next, we need to restart the SSH daemon service.
# systemctl restart sshd OR # /etc/init.d/sshd restart
Now try to log in with the root user, you will get a “Permission denied” error.
$ ssh root@192.168.0.102 root@192.168.0.102's password: Permission denied, please try again.
So, from now onwards login as a normal user and then use the ‘su’ command to switch to root user.
$ ssh root@192.168.0.102 tecmint@192.168.0.102's password: Last login: Mon Dec 27 15:04:58 2021 from 192.168.0.161 $ su - Password: Last login: Mon Dec 27 15:05:07 IST 2021 on pts/1
No comments:
Post a Comment