Simply put, two lines of commands
sudo vim /etc/ssh/sshd_config
# 新增 Port xxx
sudo service sshd restart
1. Add new port
sudo vim /etc/ssh/sshd_config
Open the file and edit it. For example, if you want to add port 1022, add a line
Port 1022
If the original 22 port is in comment state, uncomment it, otherwise port 22 will not be able to connect, and can only be
saved and exited through 1022 connection
. If it is upgraded to openssh service, it is also possible to change /user/local/etc/sshd_config
2. Restart the ssh service to take effect
sudo service sshd restart
3. Check whether the port is listening in the listen state
sudo netstat -plnt | grep sshd
4. Log in via ssh using the new port
ssh [email protected] -p 1022