How To Prevent SSH Root Access

February 7th, 2008 · 1 Comment

While this is a well know security measure, I still see so many Linux servers that allow root login through SSH that I thought I’d post it here.

Before you make change to your Linux box, make sure that you’ve got a normal user account created otherwise you’ll lock yourself out unless you’ve got physical access to your server. Here’s how you can add a user account through command lines:

# adduser newusername
# passwd newusername


To prevent SSH root login on CentOS 5.1 / RHEL 5, edit /etc/ssh/sshd_config with your favorite file editor:

# vi /etc/ssh/sshd_config

And find the line that contains:

#PermitRootLogin yes

Uncomment the parameter and set its value to ‘no’:

PermitRootLogin no

Now save the change and exit the editor. Restart sshd service to apply the change.

# service sshd restart

From now on you will not be able to login as root first. You will have to login as a normal user and then become root by issuing:

# su - root

1 response so far ↓

1. Response by : How To Move A Website Between Webservers Using cPanel / WHM on May 5, 2008 at 12:04 am

[...] Before we go any further, you must ensure that the root user can connect to the source server through SSH. This is usually forbidden but you can permit it for the time you will be copying accounts. Read this tutorial for more information on enabling and disabling SSH root access. [...]

Leave a Comment




Posted in Linux · Tutorials | 1 Comment

Dedicated Servers
 
VPS
Website Hosting
 

Recent Comments

Recent Webmasters

Hosting Type :
Monthly Price :
Storage :
Transfer :
Sort By :
Search