美文网首页
CentOS7修改SSH端口

CentOS7修改SSH端口

作者: 有事找叮当 | 来源:发表于2020-09-16 18:02 被阅读0次

一、修改ssh配置文件sshd_config

[root@bogon ~]# vi /etc/ssh/sshd_config


二、防火墙放行

[root@bogon ~]# firewall-cmd --zone=public --add-port=22345/tcp --permanent

[root@bogon ~]# firewall-cmd --reload

三、向SELinux中添加修改的SSH端口

先安装SELinux的管理工具 semanage (如果已经安装了就直接到下一步) :

[root@bogon ~]# yum provides semanage

安装运行semanage所需依赖工具包 policycoreutils-python:

[root@bogon ~]# yum -y install policycoreutils-python

查询当前 ssh 服务端口:

[root@bogon ~]# semanage port -l | grep ssh


向 SELinux 中添加 ssh 端口:

[root@bogon ~]# semanage port -a -t ssh_port_t -p tcp 22345



重启 ssh 服务:

[root@bogon ~]# systemctl restart sshd.service

测试成功后,把22端口注释掉即可

相关文章

网友评论

      本文标题:CentOS7修改SSH端口

      本文链接:https://www.haomeiwen.com/subject/zgshyktx.html