How to change the SSH port
- Log in to the server with root user
- Open /etc/ssh/sshd_config.
- Edit the port line. Change the default port 22 to your choice, for example 1234.
- Restart SSHD
- Test SSH while specifying the new port
ssh USER@HOSTNAME -p1234
- Please use your USER and HOSTNAME and the new port
- If unsuccessful, add the new SSH port to your firewalls and then retest.
- If the SSH test on the new port is successful then you can reboot and log in to the server with new port.