This article introduces the steps on how to change the SSH port.
1 Log in to the server.
2 Edit the SSH configuration file.
3 Save the configuration file and exit.
4 Restart the SSH service.
5 Log in to the server with the new port.
For how to log in to the Linux server, please refer to How to SSH to a Linux Server. If the system is Ubuntu OS, please switch to root user with the command "sudo-i".
# sudo -i
The SSH configuration file is sshd_config. You can use "vi" to edit the configuration. First, enter the command below
# vi /etc/ssh/sshd_config
Next, type "/Port" to search for the
Please note that the port number must be between 1024 and 65536.
Save the configuration file and exit with the command ":wq".
Restart the SSH service for the configuration to take effect.
# service sshd restart
After you change the SSH port, the session breaks. You need to log back in to the server using the new port.