How to Change the Default SSH Server Port on Ubuntu

How to Change the Default SSH Server Port on Ubuntu

This is a really simple and quick tutorial on how to change the default port on an SSH server to a custom port.

Changing the Default SSH Server Port

SSH uses port 22 by default, this is industry standard and there are good reasons for it, however as it is universally known, malicious actors also know which port your ssh server is likely running on. In this tutorial we will cover how to change the default ssh server to a less common port of your choice, preventing hackers from attempting to brute force their way into your server.

Log into your remote server and navigate to the ssh config file located at /etc/ssh/sshd_config and open the file with your favorite editor, find the “Port” setting, you will see it is set to “22”. Uncomment the line and change the port number to a custom port value (you may want to avoid using well-known ports see: https://en.wikipedia.org/wiki/List_of_TCP_and_UDP_port_numbers) Be sure your firewalls are configured to allow incoming traffic to the new port. 

Then restart your ssh server via: 

							
							
					sudo systemctl restart ssh				
			

NOTE: Ensure all firewalls are configured to allow the appropriate traffic via the new port so that you don’t lock yourself out of your server. I would recommend testing the ssh connection via the new port before logging off of the machine, in case there are connectivity issues you can fix them before locking yourself out. 😉

That’s a wrap! 

Walter Miely is a tech entrepreneur and CEO of Phoenix Ignited Tech You can find him on Linkedin. This material is licensed under the CC BY 4.0 License LEGAL DISCLAIMER: The content provided here is provided AS IS, and part of, or the entirety of this content may be incorrect. Please read the entireLegal Disclaimer here.