How to Change SSH Port

change ssh portHackers are out there trying to brute force into your servers by using different tools. One of the first accounts they target is Root account and the port for ssh which is 22. One of the methods to discourage such novice hackers is to change the SSH Port because hackers would be discouraged when they will not find SSH listening on the default port of 22. This practice is called Security by Obscurity. Here is how you can change SSH port in under a minute:

Step One:

The first step in the process to change SSH port is to Log in to your server using Putty and use the following command to edit the SSH configuration file by using the linux editor named pico:

pico    /etc/ssh/sshd_config

Now you need to find the word port in the text that has opened in editor . For this , press crtl + w and type ‘port’ without quotes to find the line in the file where port appears.

Step Two:

Change SSH port number to other than 22 and after that type CTRL + X to save the changes. When asked for confirmation , press Y .

Step Three:

Next we need to restart the SSH daemon for the changes to take effect for the current session. Type the following command and hit enter:

/etc/rc.d/init.d/sshd restart

You will also need to allow the new port in  your firewall if you have one in place like CSF or APF . This tutorial works for Centos, Ubuntu , Debian and other Linux flavors. I hope you liked this simple tutorial to change SSH port.

Image

Leave a Reply