1、修改文件 vim /etc/ssh/sshd_config
[root@ecs-365715 ~]# vim /etc/ssh/sshd_config
2、修改内容
# Port 22 // 默认使用的是22端口
Port 50000 // 添加此句表示使用50000端口,如果想兼容两者,就讲上述#去除
3、重启ssh服务
[root@ecs-365715 ~]# systemctl restart sshd.service
4、查看端口
[root@ecs-365715 ~]# netstat -ltnp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:50000 0.0.0.0:* LISTEN 6231/sshd // 看到此句表示上述修改已生效
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 6231/sshd
tcp6 0 0 :::50000 :::* LISTEN 6231/sshd
tcp6 0 0 :::22 :::* LISTEN 6231/sshd
5、修改服务器运营商的网络安全组,开启50000端口访问即可