How to change ssh port or add ssh port
Adding ports
- make sure you have ssh service installed properly.
- sudo nano /etc/ssh/sshd_config to edit the config file
- add new port by adding new line of "Port 2222" (in this case, 2222 is your new ssh port)
- restart ssh service by using "sudo systemctl restart sshd.service"
Set new firewall rule
- Go to aliyun console.
- Go to firewall setting and press new rule. 进入安全-防火墙,点击添加规则
- Add a new rule for 2222. 添加自定义规则,Tcp,端口号 (本例中是2222) 你可以自行替换
Testing
- ssh username@youip -p 2222
- success~