How to change ssh port or add ssh port
Summary: How to change ssh port or add ssh port. So you can login ssh where port 22 are not allowed.
 aliyun  ssh  server

Adding ports

  1. make sure you have ssh service installed properly.
  2. sudo nano /etc/ssh/sshd_config to edit the config file
  3. 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
  4. restart ssh service by using "sudo systemctl restart sshd.service"

Set new firewall rule

  1. Go to aliyun console.
  2. Go to firewall setting and press new rule. 进入安全-防火墙,点击添加规则 1
  3. Add a new rule for 2222. 添加自定义规则,Tcp,端口号 (本例中是2222) 你可以自行替换 2


  1. ssh username@youip -p 2222
  2. success~ 4FEAF6A4-1755-4587-8E33-87F88C3DA09B.png
Latest Updated Time:2019-09-04 14:26:55