how to deny root ssh access in linux server

how to deny root ssh access in linux server

For security point of view we generally restrict root direct ssh access in server.But keep in mind you also must have user who can access the server other than root.
So before doing this practical ,check if you have access to server with other user or else create a new user with password.

useradd username

passwd username

OK, now restrict the root from ssh follow the given below steps

Step 1 : Take the backup of sshd_config file

cp -p /etc/ssh/sshd_config  /etc/ssh/sshd_config.backup

Step 2: Edit the sshd_config file and search for keyword PermitRootLogin
Bydefault PermitRootLogin is yes. Change the PermitRootLogin yes to no

vi /etc/ssh/sshd_config

PermitRootLogin no

Step 3: After this change restart the ssh service.

In CentOs and Red Hat

/etc/init.d/sshd restart

In Debian and Ubuntu

/etc/init.d/ssh restart

Now you can check it, use command ssh root@server-ip-Or-FQDN

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.