Box-sizing: border-Box; font-weight: 500; line-height: 1.225; color: rgb(51,51,51); margin: 1.5em 0px 0.6em; font-size: 30px; padding-bottom: 0.3em; border-bottom: 1px solid rgb(238,238,238); white-space: normal;">linux修改默认ssh端口,centos修改ssh端口
Box-sizing: border-Box; font-weight: 500; line-height: 1.1; color: rgb(51,51); margin-top: 1.6em; margin-bottom: 0.6em; font-size: 20px; white-space: normal;"> Box-sizing: border-Box; font-weight: 700;">一: 修改ssh配置文件(将Port注释去掉 改为你需要设置的端)
vim /etc/ssh/sshd_config
例如:Box-sizing: border-Box;font-size: 14.4px; padding: 2px 4px; color: inherit; background-color: rgba(0,0.0392157); border-radius: 4px;">Port 20022
Box-sizing: border-Box; font-weight: 500; line-height: 1.1; color: rgb(51,51); margin-top: 1.6em; margin-bottom: 0.6em; font-size: 20px; white-space: normal;"> Box-sizing: border-Box; font-weight: 700;">二: 将设的端口加入防火墙
vim /etc/sysconfig/iptables #加入端口 -A INPUT -p tcp -m tcp --dport 20022 -j ACCEPT
Box-sizing: border-Box; font-weight: 500; line-height: 1.1; color: rgb(51,51); margin-top: 1.6em; margin-bottom: 0.6em; font-size: 20px; white-space: normal;"> Box-sizing: border-Box; font-weight: 700;">三: 重启ssh和防火墙
service sshd restart service iptables restart
注意:如果你是阿里云服务器请将设置的端口加入安全组才可正常访问