Centos7 修改SSH端口

  1. 修改SSH配置文件
    找到/etc/ssh/sshd_config
    #Port 22 修改为所需端口 Port 10086 去掉井号

  2. 查看SELinux开放给ssh使用的端口

semanage port -l | grep ssh   查看 
semanage port -a -t ssh_port_t -p tcp 10086  增加
semanage port -d -t ssh_port_t -p tcp 10086  删除

如果提示 semanage:command not found 就安装一下
a.使用yum查找提供此功能的软件包
#yum provides semanage

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile

* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.cn99.com
base/7/x86_64/filelists_db | 7.3 MB 00:00:29
extras/7/x86_64/filelists_db | 207 kB 00:00:00
updates/7/x86_64/filelists_db | 1.4 MB 00:00:04
policycoreutils-python-2.5-33.el7.x86_64 : SELinux policy core python utilities
Repo : base
Matched from:
Filename : /usr/sbin/semanage

b.安装软件包
#yum install policycoreutils-python -y

  1. 查看防火墙
firewall-cmd --permanent --query-port=10086/tcp  查看 
firewall-cmd --permanent --add-port=10086/tcp  增加
firewall-cmd --permanent --remove-port=10086/tcp  删除
  1. 重启SSH 重启防火墙
systemctl restart sshd.service
systemctl restart firewalld.service 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

sinqi_SG

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值