Enable/Disable ssh access to root

Its always better to disable ssh access to root user which will protect the server from any attacks. Its kind of additional security layer on top of firewall.

There are 2 ways to disable SSH access to root.

With DenyUsers:

In /etc/ssh/sshd_config file search for line DenyUsers, if it exists edit it as follows else add following line:

DenyUsers root

If you want to disable ssh login for multiple users on the server add as following:

DenyUsers root user1 user2 user3

After updating sshd_config add restart sshd service with following command:

$ service sshd restart

Now try to ssh to root, it should not allow login even though you entered right password.

With PermitRootLogin:

PermitRootLogin will support 2 options “yes” and “no”.

Option yes will allow ssh to root and option no wont allow ssh to root.

To allow ssh to root add following line in /etc/ssh/sshd_config file and restart sshd service:

PermitRootLogin yes

To disable ssh to root add following line in /etc/ssh/sshd_config file and restart sshd service:

PermitRootLogin no

-Sany

About these ads

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s