Introduction
This article covers changing the SSH port.
Procedure
1) Configure any firewalls that may restrict traffic to the server to allow traffic to the new SSH port.
2) Log in to the server using the current SSH port (default 22). Note that you should not close this SSH connection until you have verified that you can access SSH on the new port number.
3) Set the Port line in /etc/ssh/sshd_config. If the line does not exist it can be added, and if it is commented out, it can be uncommented or added. Commented lines will start with a # character, which can be removed to uncomment them. The Port line will look like this, where 1234 is replaced with the port number you'd like to use.
Port 1234
4) Restart SSHD.
/scripts/restartsrv_sshd
5) Test SSH while specifying the new port. An example of how to specify port 1234 in SSH on Linux is shown below. This will vary based on the SSH client used.
ssh USER@HOSTNAME -p1234
6) If the SSH test on the new port is successful you can close the connection used to change the port and proceed with any other changes you may wish to make, such as closing the previous SSH port. If it is not successful, you will need to troubleshoot using the current working SSH connection. This SSH connection should not be closed until the SSH test on the new port is successful.