-
修改SSH配置文件
找到/etc/ssh/sshd_config
#Port 22 修改为所需端口 Port 10086 去掉井号 -
查看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
- 查看防火墙
firewall-cmd --permanent --query-port=10086/tcp 查看
firewall-cmd --permanent --add-port=10086/tcp 增加
firewall-cmd --permanent --remove-port=10086/tcp 删除
- 重启SSH 重启防火墙
systemctl restart sshd.service
systemctl restart firewalld.service