Let's talk about SELinux ports, because we've been talking about files and directories.
Reports are also part of the SELinux security.
So network ports are provided with an SELinux context label, and the SELinux policy is configured
to allow default port access.
So you run your web server on ports 80 and 443, nothing wrong.
You run your SSH on port 22, nothing wrong.
But for any non-default port access, you need SEManagedPort to apply the right label to
the port.
It's not so hard compared to files.
And the best thing to do is have a look at the man page for SEManagedPort.
So let's check it out, and let's run something on a non-default port.
So I am going back to etc ssh sshd underscore config.
And there we can see this port line.
And hey, look above.
Do you see that?
It's telling us if you want to change the port, you need to tell SELinux about it, SEManagedPort
minus A minus C SSH port T minus P TCP port number.
Well, that's easy.
So that means that if I copy this, and I change my port, I like to change it to port 2022.
I do need to remove the hash, because otherwise it won't be efficient.
And next, I'm pasting everything, and I'm changing the port number to 2022.
Well, this should be doing it.
So systemctl restart sshd, and it should be able to service that port.
SS minus 2NAPZ is showing information, and here we can see that we have port 2022, which
is correctly set to sshd underscore T. That is how easy it can be.