How to change default SSH port for a VPS or Dedicated server.

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:

vi /etc/ssh/sshd_config

Look for the line that says something along the lines of the following:

Port 22
#AddressFamily any
#ListenAddress ::

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:

/etc/init.d/ssh restart

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. 

That's it!

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
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Enable DKIM and SPF on existing cPanel Accounts

To add domainkeys and SPF records, you can do the following. Please note that on CPanel servers...

How to install CHKRootkit

Install CHKROOTKIT Product Name: CHKROOTKIT Product Version: 0.49 Homepage:...

How to Install CSF Firewall

Installing a firewall on your VPS is of vital importance. One of the most respected, and widely...

How to install Malware Detect (Maldet) for CentOS 6 / Linux

Malware Detect is very easy to install on CentOS, regardless of the control panel you utilize...

How to secure /tmp

his will cover securing /tmp /var/tmp and /dev/shm Secure /tmp: Step 1: Backup your /etc/fstab...

Powered by WHMCompleteSolution