让SSHD在运行SELinux的情况下收听Centos上的另一个端口

前端之家收集整理的这篇文章主要介绍了让SSHD在运行SELinux的情况下收听Centos上的另一个端口前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个运行SE Linux的Centos VM.我希望让sshd听另一个端口—说,993.我已经修改了sshd_config文件来监听另一个端口,但是SELinux正在阻碍它.我不想禁用SELinux.我怎么告诉SELinux sshd可以在端口993上读取TCP连接?

要使用的正确命令是semanage port -a -t ssh_port_t -p tcp 993但我无法使用该命令,因为端口993已在另一个策略中使用:

[centos@timedb ~]$semanage port -a -t ssh_port_t -p tcp 993
ValueError: SELinux policy is not managed or store cannot be accessed.
[centos@timedb ~]$

但是我不能删除策略中的那个端口,因为它是基本策略的一部分:

[centos@timedb ~]$sudo semanage port -l|grep 993
pop_port_t                     tcp      106,109,110,143,220,993,995,1109,10993
[centos@timedb ~]$sudo semanage port -d -t pop_port_t -p tcp 993
ValueError: Port tcp/993 is defined in policy,cannot be deleted
[centos@timedb ~]$

我需要使用已经定义的端口,因为我位于中间盒的上游,只允许在分配给指定服务的端口上进行连接,并且端口22被阻止.

解决方法

使用semanage(8)允许它.
# semanage port -a -t ssh_port_t -p tcp 993
原文链接:https://www.f2er.com/linux/395571.html

猜你在找的Linux相关文章