1.3 KiB
1.3 KiB
RHCSA 10.6: SELinux port labels
Letting httpd and sshd listen on ports SELinux doesn't expect them on.
Before you start
SELinux must be enforcing; keep it that way. The lab installs and starts
httpd on port 80, installs policycoreutils-python-utils (for
semanage), and adds a second machine, peer (10.99.0.2), on the lab
network 10.99.0.0/24 (this VM is 10.99.0.1 there), to test from. Get a
shell there with sudo ip netns exec lepeer bash. Keep a console or a
second session open while you change sshd.
Tasks
- Make httpd listen on port 8888 as well as 80, with SELinux enforcing,
reachable from other systems: from the peer,
curl http://10.99.0.1:8888/gets an answer. Open the firewall if it's running. - Move sshd to port 2222, keeping port 22 working until you've tested it:
add
Port 22andPort 2222in a file in/etc/ssh/sshd_config.d/.ssh -p 2222 localhostworks.
Hints
Listen 8888in a file in/etc/httpd/conf.d/;systemctl restart httpdfails untilsemanage port -a -t http_port_t -p tcp 8888;semanage port -l -C;ss -tln. Iffirewall-cmd --statesays running:firewall-cmd --permanent --add-port=8888/tcp,--reload.semanage port -a -t ssh_port_t -p tcp 2222,sshd -t,systemctl restart sshd.