侧边栏壁纸
博主头像
落叶人生博主等级

走进秋风,寻找秋天的落叶

  • 累计撰写 130562 篇文章
  • 累计创建 28 个标签
  • 累计收到 9 条评论
标签搜索

目 录CONTENT

文章目录

CentOS7修改sshd端口

2023-11-09 星期四 / 0 评论 / 0 点赞 / 53 阅读 / 1538 字

因安全检查要求,需将sshd端口由22更改为6802。1.修改sshd_config,将Port 22更改为6802[root@localhost ~]# vi /etc/ssh/sshd_confi

因安全检查要求,需将sshd端口由22更改为6802。

1.修改sshd_config,将Port 22更改为6802

[root@localhost ~]# vi /etc/ssh/sshd_config # If you want to change the port on a SELinux system, you have to tell# SELinux about this change.# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER#Port 6802#AddressFamily any#ListenAddress 0.0.0.0#ListenAddress ::

或者

echo 'Port 6802' >> /etc/ssh/sshd_config

2.利用semanage工具,添加6802端口到SELinux。

CentOS默认安装没有semanage工具,需安装

yum install policycoreutils-python

查看sshd原有端口

semanage port -l |grep sshssh_port_t                     tcp      22

添加6802端口

semanage port -a -t ssh_port_t -p tcp 6802

验证6802已添加

semanage port -l |grep sshssh_port_t                     tcp      6802, 22

3.因CentOS默认防火墙只开启了22端口,需在防火墙放开6802端口或关闭防火墙。

防火墙放开6802端口命令:

firewall-cmd --zone=public --add-port=6802/tcp 

查看6802端口打开状况

[root@localhost ~]# firewall-cmd --query-port=6802/tcpyes

关闭防火墙命令:

systemctl disable firewalldsystemctl stop firewalld

4.重启sshd。

systemctl restart sshd

广告 广告

评论区