CentOS, Fedora and FreeBSD by default have the port set to 22, to log in over SSH. Here’s how to change that port.
Firstly, edit the SSH configuration file to enable this:
Find the line:
and change it to:
Port 2222 (Or a port of your choice, make sure it doesn’t overlap with any other ports in use on this machine!)
You need to remove the hash ‘#’ from the start of the line (uncomment the line) and then change ‘22’ to a port of your choosing, save the file and then restart SSH:
You should now be able to log-in over SSH on your desired port number! Be sure to update any firewall configurations to reflect this change, or you may get locked out!