Configuring SSH Port & Disabling Direct Root Login

Changing the SSH port & disabling root login is something that everyone should do as it adds an extra level of protection to your server.

Login to your server using root

Edit /etc/sshd/sshd_config

At the top of the file, you will see something similar to:
Port 22
Protocol 2, 1

Change the Protocol line to 2

The port option, it really is up to you what port you use. Just make sure with netstat that it is not being used for anything else. Some common secondary SSH ports are 1024 or 2222.

Scroll down and disable direct root login
PermitRootLogin no

If there is a # in front of the line, make sure to remove it. Now just save the file and exit your editor.

Restart SSH:
/etc/init.d/sshd restart

That’s it, try opening a new session without closing the existing one, just in case you need to roolback the changes or edit anything and check ifi t’s done.

Advertisements

Leave a Reply

Please log in using one of these methods to post your comment:

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