I need to be able to run SSH on port 23 instead of 22 on CentOS 6.5. SElinux won't allow that, as it has it as tcp/23 defined in policy. Any steps on how can I go about changing service type from telnetd_port_t to sshd_port_t?

  • You can use semanage port to change types. – Bratchley Oct 5 '15 at 19:06
  • semanage port does not change types of ports defined in policy of SELinux. Although I can use it to change service types of undefined ports – Gaurav Oct 5 '15 at 19:22

Bratchley was on the right track. Indeed 'semanage' can change (modify) already defined ports.

Here's a way that worked for myself:

[root@host ~]# semanage port -l |grep ssh
ssh_port_t                     tcp      22
[root@host ~]# semanage port -m -t ssh_port_t -p tcp 23
[root@host ~]# semanage port -l |grep ssh
ssh_port_t                     tcp      23, 22

From here, you can modify SSHD to listen/use port 23 in /etc/ssh/sshd_config, restart the 'sshd' service and adjust your firewall as necessary.


I am no friend of SELinux, so this is just a wild guess: Modify /etc/services so that 23/tcp has the same entry as 22/tcp?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.