How to set SSH to run on a non-standard port

By default, the OpenSSH server runs on TCP port 22. Changing this to a non-standard port helps mitigate the risk of someone successfully gaining access via a brute force attack, especially if there are many users on the system or if someone users use less secure authentication options. Don’t forget to open the port in your firewall to avoid being locked out.

Edit the SSH config file using the following command:

nano /etc/ssh/sshd_config

Change the line:

Port 22 to whatever number you wish.

It’s important that you don’t set SSH to run on a port that is reserved for another protocol / service. Wikipedia has a list of known ports that may be helpful in this regard: http://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers

This entry was posted in FAQ and tagged , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *