Home / How to configure SELinux to allow SSHD running on custom port

How to configure SELinux to allow SSHD running on custom port

Install the semanage command as follows.

CentOS 5 rpm: policycoreutils

CentOS 6 & 7 rpm: policycoreutils-python

CentOS / AlmaLinux 8 rpm: policycoreutils-python-utils

Execute the following command, replacing PORT with the desired TCP port number (11111).

# semanage port -a -t ssh_port_t -p tcp PORT

If a standard port is chosen, such as 443, the command will error output with the message.

 Port tcp/XXX already defined

Re-run the command after changing the -a (add) option to -m (modify).

# semanage port -m -t ssh_port_t -p tcp PORT
Execute the following command to view the current list of ssh_port_t type ports.
# semanage port -l | grep ssh_port_t
To view any customization of the port policies, execute the following command.
# semanage port -l -C

Leave a Reply