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




 

Top 10 Linux Hosting Providers

InMotion Hosting - $5.95
WebHostingHub - $4.95
iPage - $2.99
JustHost - $3.45
HostGator - $4.95
FatCow - $3.67
GreenGeeks - $4.95
HostMonster - $5.95
BlueHost - $6.95
10 GoDaddy - $4.31
 
 
 
 

Tutorials by Category

 
 

Recent Comments

 
© Copyright 2010 - TheWebHostingHero.com