Change the SSH port

The default SSH port is 22. If you want to change the SSH port on your Debian server to, for example, 2222, you can do so as follows:

Edit the SSH configuration file 

$ pico /etc/ssh/sshd_config

Find line with word Port

Port 22

Then change number 22 to your new port 2222

Port 2222

Then close the SSH configuration file and restart the SSH service.

Note 1: If you are connected via SSH, you will be disconnected when you restart the SSH service. Reconnect to your server using your new port.
 
Note 2: Also, don't forget to create a new SSH rule in your firewall with your new port. Don't remove your old firewall rule with port 22 until you restart SSh service and make a new connection to your server using the new port.

$ service ssh restart