步骤一:编辑配置文件
1.vim /etc/ssh/sshd_config
在原Port位置添加想要开放的端口 例如:
Port 122
2.重启ssh服务
systemctl restart sshd.service 可能会链接失败
查看ssh开放端口
semanage port -l | grep ssh
如果第二步失败 接着第三步:第二步成功部分centos版本也是需要继续走第三步的
3. 绑定对应ssh开放端口
semanage port -a -t ssh_port_t -p tcp 122
开放防火墙端口 如果防火墙开启的话
firewall-cmd --zone=public --add-port=122/tcp --permanent
firewall-cmd --reload
重启ssh服务即可
systemctl restart sshd.service