13
2019
05
10:07:50

SSH修改端口报错 error: Bind to port xxx on 0.0.0.0 failed: Permission denied.解决方法



推荐点击下面图片,通过本站淘宝优惠价购买:

image.png

SSH修改端口报错 error: Bind to port xxx on 0.0.0.0 failed: Permission denied.解决方法


Linux修改ssh Port端口后,无法启动ssh访问。

具体修改  /etc/ssh/sshd_config 里的 Port 端口,然后查日志后出现:

error: Bind to port 77 on 0.0.0.0 failed: Permission denied.

最后发现是SELinux的问题,关闭SELinux。
关闭SELinux方法:https://www.landui.com/help/show-8381

1 永久方法 – 需要重启服务器

修改/etc/selinux/config文件中设置

SELINUX=disabled


2 临时方法 – 设置系统参数然后重启服务器。

使用命令setenforce 0

附:
setenforce 1 设置SELinux 成为enforcing模式
setenforce 0 设置SELinux 成为permissive模式

然后重启ssh访问即可。



2

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

0

Port 777 is dedicated for Multiling HTTP and even though not in use you can't bind to it. If you try for example to bind to port 8777 it will work just fine.

7

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.

1

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



本文链接:https://hqyman.cn/post/697.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:





休息一下,本站随机推荐观看栏目:


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

您的IP地址是: