Changing the default SSH port to your VPS or server is recommended for security reasons, regardless of your operating system or control panel (cPanel/WHM, Plesk, etc). The following tutorial is written for CentOS 6, but can apply to a range of other Linux operating systems. The Secure Shell (SSH) Protocol by default uses port 22. Changing the default SSH port will stop many automated attacks and a bit harder to guess which port SSH is accessible from. This will not make your system bullet proof, but helps aid in security.
First login to your server as ‘root’.
Then, modify your sshd_config file:
Look for the line that says something along the lines of the following:
Change the line that says “Port 22” to the port of your choice. However, please keep in mind that common ports should be avoided (Such as 80 for apache, 21 for FTP, etc)
Save the file.
Then restart SSH so that the new port takes effect:
Now, open a seperate session using putty or your favorite SSH program, and try to connect via the new port you have assigned to SSH. Attempting to connect to the default 22 should now give you a default “connection refused” warning and stop your connection.
Note: If you are having issues connecting to your new port, make sure that your firewall has that port open or that it is not a port being used by another process.