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)
![29917F88-7D25-417A-B5C0-17D497D0C221.png]()
- 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. 进入安全-防火墙,点击添加规则
![1]()
- Add a new rule for 2222. 添加自定义规则,Tcp,端口号 (本例中是2222) 你可以自行替换
![2]()
Testing
- ssh username@youip -p 2222
- success~
![4FEAF6A4-1755-4587-8E33-87F88C3DA09B.png]()



