How to disable SSH login on server?

kumkumsharma

Administrator
Staff member
Most of the time this step will be taken for the security purpose, if you will directly access server without any restrictions then hackers can attempt brute force attack on your server.

If you want to disable SSH login for root user then you can check this article.
  • Login to server as root.
  • Then open the sshd_config file with below command;
Code:
vi /etc/ssh/sshd_config
  • You can search for “#PermitRootLogin yes’ section in this file manually.
  • You have to uncomment this line and make this directive No.
  • Now save and close this file.
  • After that restart the SSH with below command:
Code:
/etc/init.d/sshd restart
systemctl restart sshd
service sshd restart
with above steps you are able to disable the root user login via SSH. You can also try to login with SSH daemon at your end, you will get “Permission denied”.
 
Top