How to disable SSH login for the root user?

  • 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 like similar to this.
    • PermitRootLogin no
  • Next, we need to restart the SSH daemon service.
    • # /etc/init.d/sshd restart
  • Now try to login with root user, you will get “Access Denied” error.
  • So, from now onwards login as normal user and then use ‘su’ command to switch to root user.
  • 13 Users Found This Useful
Was this answer helpful?

Related Articles

Connecting to your Linux VPS

Now you received your details you’ll connect to it via SSH if you have a Linux VPS: If your...

SSH is not working?

Please follow the steps below if SSH on your server is not working - Please make sure...

How to setup VPN server (PPTP on CentOS, RedHat and Ubuntu)?

This howto describes the steps in how to setup a PPTP VPN on Centos, Fedora, Debian, and Ubuntu...

How to install OpenVPN on Linux?

apt-get install openvpn openssl udev wget...

How to change root password on Linux VPS?

If you don't remember the password, please use the following steps for changing the root password...