posted by qubix on May 6, 2016

Well...for some reason ssh failed to bind to any port other than 22

Lets check first to what port we are trying to bind to


$ cat /etc/ssh/sshd_config | grep -i port

$ Port 5678

Ok now let's check what the logs said (yes it's systemd...)


$ journalctl -u sshd.service

systemd[1]: Starting OpenSSH server daemon... sshd[10158]: error: Bind to port 5678 on 0.0.0.0 failed: Permission denied. sshd[10158]: error: Bind to port 5678 on :: failed: Permission denied. sshd[10158]: fatal: Cannot bind any address.

Permission denied? I bet it is because selinux is in enforce mode! So the solution is to add the port we want to the selinux policy about ssh.

Firstly lets install the policy utils


$ yum install policycoreutils-python

Check current policy for ssh


$ semanage port -l | grep ssh

ssh_port_t tcp 22

And add to it our desired port


$ semanage port -a -t ssh_port_t -p tcp 5678
ready!

hyperworks