Ubuntu / Debian
Open the SSH configuration file with your favorite text editor and find the lines that specifies the SSH port.
Uncomment the relevant line by removing the # sign and change the default port 22 to the one that you want to use. In this article we will use port 1012.
Save the changes and exit.
Restart SSH service
Restart the SSH service for the changes to take effect.
service sshd restart