Wednesday, January 27, 2010

Howto: disable root login

How to disable root login and secure SSH server? In order to disable root access on your server, make sure you create a user who have privileges to gain root access. Create a user say, ‘admin’ (you need to add the user ‘admin’ to the wheel group in case you are on a cPanel server) and follow the steps to disable root access and secure SSH:

1) Edit the SSHD configuration file:

pico /etc/ssh/sshd_config

2) Search the line

PermitRootLogin yes
and change it to
PermitRootLogin no

3) To change the default SSH port, search for the line

#Port 22
and change it to
Port 2233

4) To make SSH work on a secure protocol, search the line

#Protocol 2, 1
and change it to
Protocol 2

5) In order to make SSHD service listen to a specific IP, searcg the line

#ListenAddress ::
change it to
ListenAddress AdditionalIPofServer

Once you are complete with the above changes, save the file and exit. You will have to restart the sshd service for the changes to take effect. Now, you will have to login to your server as user ‘admin’ and then su to root as follows:

Hostname: Server IP
User: admin
SSH Port: 2233
Pass: password of user ‘admin’

Once logged in, execute su -and it will prompt you for the root password.

No comments:

Post a Comment