How To Disable SSH For Remotely Root Login In CentOS 7

It’s a good idea how to disable SSH remote login on the server for security reasons. You just need to make a small change in the configuration file and give ssh access without a password login. you can create a user to give access on the server with username and password in the Linux server. Sometimes, you will see ssh root login permission denied please try again.

How To Disable SSH For Remote Server:

We can do this because of security purposes on the server and should not allow the root login on the server because the default user is root. we can have a remote session of the server by creating a new user and assign the root permission to the user.

Check OutHow To Update Windows Driver Using These Methods

Step 1: Create a user on Linux using the below command. 

[root@master-node ~]# useradd test
[root@master-node ~]# grep test /etc/passwd

If you want to give sudo permission then you have to add ‘test’ user in the wheel group.

[root@master-node ~]# usermod -G wheel test
[root@master-node ~]# grep test /etc/group

Step 2: you want to run this user as root executes the command. So, we have to add this user in /etc/sudoers

[root@master-node ~]# echo 'test ALL=(ALL) ALL' >> /etc/sudoers

Check OutHow To Install OpenSSH

Step 3: So, they do work using their credentials and it will be easier for you to identify what they’re doing and what they have done. you can apply an ssh connection timeout for a remote session in the Linux server. 

Now make some changes in the ssh configuration file.

vim /etc/ssh/sshd_config

ssh root login

Change PermitRootLoginYes” to “No

 disable ssh remote login

Check Out: Create SSH Key

Save the file and restart the sshd service using the below command.

[root@master-node ~]# systemctl restart sshd

You’re done ssh login without password permission denied please try disable ssh remote login ssh root login

Share on:

I'm the founder of Curious Viral. I hope this blog will provide you complete information about Linux Technology & I would like to share my technical knowledge with you which I have learned during this period.

Other Posts You May Like...

Leave a comment