Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CentOS 6.3. SSH. Bind to port xxx on 0.0.0.0 failed: Permission denied

Tags:

ssh

centos

CentOS 6.3 Minimal Configuration. Installed SSH Server, port 22. All works correctly. I change port 22 on 777 and restart sshd and see in logs:

Jul 26 01:01:07 myserver sshd[1590]: error: Bind to port 777 on 0.0.0.0 failed: Permission denied.
Jul 26 01:01:07 myserver sshd[1590]: error: Bind to port 777 on :: failed: Permission denied.
Jul 26 01:01:07 myserver sshd[1590]: fatal: Cannot bind any address.

/etc/sysconfig/iptables contains:

-A INPUT -m state --state NEW -m tcp -p tcp --dport 777 -j ACCEPT

netstat -tulpn | grep :22 and netstat -tulpn | grep :777 return nothing

like image 439
indapublic Avatar asked Jul 26 '12 15:07

indapublic


2 Answers

Centos uses SELinux by default and I don't think Ubuntu does (or least I've not seen it). Have a look for SElinux permission errors in your logs too.

like image 121
Net Wolf Avatar answered Jan 02 '23 20:01

Net Wolf


SELinux does not allow sshd to be run on another port on a default install of CentOS 6.3. Follow -> https://blog.tinned-software.net/change-ssh-port-in-centos-with-selinux/ :

  • dig a hole into your firewall (you already did that)
  • add a rule for SELinux to allow sshd to be run on port 777: sudo semanage port -a -t ssh_port_t -p tcp 777
like image 27
Christian Ulbrich Avatar answered Jan 02 '23 21:01

Christian Ulbrich