Original website: Ubuntu modification settings series - method of modifying ssh port number (with examples)_IT sharp knife unsheathed blog-CSDN blog
Introduction
illustrate
This article introduces how to modify the ssh port number in Ubuntu (with examples).
goal to be achieved
ssh adds a port: 3333, and closes the original port 22.
1. Modify the port
Modify the configuration file /etc/ssh/sshd_config
sudo vi /etc/ssh/sshd_config
Add the following 2 lines at the end of the configuration file:
Port 22
Port 3333
Here port 22 has not been deleted for the time being to save the way, in case the new port cannot be connected but the default port is closed again, it will be troublesome.
2. Restart the SSH service
sudo service ssh restart
3. Test the new port
If you are prompted when you log in to SSH: no route to host, it should be that the firewall has not configured the corresponding port, just set the firewall.
4. Close port 22
Modify the configuration file: /etc/ssh/sshd_config, close port 22 in the configuration file
# Port 22
Port 3333
5. Restart the SSH service
sudo service ssh restart