How to change the ssh port on Linux or Unix server
By default, port 22 is used to establish an SSH connection. This port is automatically configured during the installation of your operating system.
To reduce the number of brute force attacks, you can configure another port for SSH access.
Before changing the port, please make sure that the applications and services installed on the server can be configured without a default port. Otherwise, changing the default port may cause these applications and services to stop working.
To make sure you can back up the sshd_config file first:
cp /etc/ssh/sshd_config /etc/ssh/sshd_config.bak
1, Open the SSH configuration file sshd_config with the text editor vi:
2, Search for the entry Port 22.
3, Replace port 22 with a port between 1024 and 65536.
4, Restart the service.
systemctl restart sshd
service ssh restart