Howtos / Articles

How To Disable root Logins Over SSH on CentOS

Most Linux distributions allow the root user to connect in via SSH, and CentOS is no exception. It is recommended that root logins are never used, and you should use either su or sudo to elevate the permissions of a normal user account. As such, the best option is to disable root logins in the SSH server configuration file.

Note: these commands should be run as a user with root privileges (sudo or su), or from the console as root.

Open the /etc/ssh/sshd_config file in your editor of choice (vi in this example):

# vi /etc/ssh/sshd_config

There should be a line containing the following:

#PermitRootLogin yes

Edit this to read:

PermitRootLogin no

(Make sure you un-comment the line too)

Save the file and exit the editor.

Restart the SSH server:

# service sshd restart


# /etc/init.d/sshd restart

Root logins over SSH should now be disabled.

Share this howto article!
  • Facebook
  • Twitter
  • Reddit
  • email

Leave a Reply




You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>