Change SSH Port in Four Simple Steps

changesshportSSH is the Secure Shell protocol which uses the port 22 as the default value. The main purpose of using this protocol is to provide security over a network of two or more connected computers. Changing the SSH port from the default value of 22 to some other user defined value is a method used to make the network more secure. One thing should be kept in mind here: using the default value for the network does not make it insecure but the added benefit of using a user defined value is the improved protection against automated cyber-attacks. As the port number is not known automatically (as would have been the case if the default value would have been used) this decreases the chances of such an automated attack being successful to a great extent.

Here we are going to discuss the steps to change the SSH port in a Linux based system and before we move towards these steps, it is very important for you have a basic understanding of how a Linux system works. Here is a great course about the basics of a Linux system and this course will equip you with all the basic knowledge required to understand the steps being discussed here. 

We are going to work on a Linux based system here. Linux is basically an operating system and has been gaining a lot of popularity in the recent times in a market dominated by the more fancied windows operating system. Here is a nice article about the important features of both these operating systems. This article compares these two operating systems and can be of great help for making a learned choice between the two. 

Now, as we have a basic idea about the working of a Linux system, we are going to discuss the basic steps for changing the SSH port.

Step One: Edit the SSHD Configuration File

The first step for changing the SSH port is to configure the sshd file. You will have to enter the system as the root and then you can configure or edit the sshd file using any of your favorite text editors.

The syntax to be used is:

td /etc/ssh/sshd_config

Here, td is any text editor of your choice. This is a great course which will give you a better idea about using text editors for Linux and about configuring files in a Linux based system. 

Step Two: Change the Port Number

The second step is pretty simple. You just need to find the line which contains the value ‘Port 22’ and edit it accordingly. You can chose any port as per your choice but a few points should be kept in mind. The port numbers from 0 to 1023, also called well known ports, should not be used. Port numbers from 1024 to 49151, called registered ports should also be avoided. Though these ports can be used, but it is advised against using them to prevent any complications in the future. Port numbers 49152 to 65535, called dynamic or private ports can be used for this purpose. Here is a great course about the security module of CCNA which will give you a better understanding about all the protocols and the different ports. 

Step Three: Switch Over to the New Port

After selecting a new port, the next step would be to move over to this new port. This can be done by restarting SSH. The syntax to be used is:

/etc/init.d/ssh restart

Step Four: Verify the Changes

The last and final step would be to verify the new port. The syntax to be used is:

ssh user_name@host_name.com –p 55673

Here user_name is the username of the user and host_name is the name of the service provider. 55673 is the value which has been selected as the new port number. Any value from the dynamic or the private port numbers can be chosen here.

So in these four simple steps you can change the value of the SSH port and make your network more secure against all kinds of automated attacks. These steps, though are easy to follow, can be understood in an even better way if supplemented with right kind of practical training. Here is an amazing course about working with a Linux based system which will explain all the concepts which have been discussed here in proper detail.