First modify the port configuration file
sudo vi /etc/ssh/sshd_config
turn upPort 22
You can directly change 22 to the port you want
You can also add it below Port ${你想设置的远程登陆端口}
. After adding it, you can use 22 and the newly added port to log in at the same time.
Press esc
, enter :wq
, save and exit
Restart the ssh service
sudo systemctl restart sshd
Ps
If you still can't log in using this port, confirm whether the firewall has opened this port.