随笔 - 178  文章 - 0  评论 - 19  阅读 - 54万

修改ssh端口号之后报错:error: Bind to port xxxx on 0.0.0.0 failed: Permission denied.

报错内容:

[root@BabyishRecent-VM ~]# vi /etc/ssh/sshd_config 
[root@BabyishRecent-VM ~]# systemctl restart sshd
Job for sshd.service failed because a configured resource limit was exceeded. See "systemctl status sshd.service" and "journalctl -xe" for details.
[root@BabyishRecent-VM ~]# journalctl -xe
error: Bind to port 3389 on :: failed: Permission denied.
d[25004]: error: Bind to port 3389 on 0.0.0.0 failed: Permission denied.
d[25004]: fatal: Cannot bind any address

查了一下,是selinux的问题,最简单的办法是关了selinux。

但是,想要开启selinux,并修改sshd的端口,需要把要添加的sshd服务端口在selinux上注册。

1、安装semanage

yum -y install policycoreutils-python

2、查看selinux中sshd当前的端口

semanage port -l | grep ssh

3、在selinux中添加端口

[root@BabyishRecent-VM ~]# semanage port -a -t ssh_port_t -p tcp 3389 
[root@BabyishRecent-VM ~]# semanage port -l | grep ssh 
ssh_port_t tcp 3389, 22

4、重启sshd服务

[root@BabyishRecent-VM ~]# systemctl restart sshd
[root@BabyishRecent-VM ~]# netstat -tunlp |grep sshd
tcp 0 0 0.0.0.0:3389 0.0.0.0:* LISTEN 25333/sshd
tcp6 0 0 :::3389 :::* LISTEN 25333/sshd

5、防火墙放行修改后的端口

[root@BabyishRecent-VM ~]# firewall-cmd --add-port=3389/tcp --permanent
success
[root@BabyishRecent-VM ~]# firewall-cmd --reload
success

 

注:

转载自https://blog.csdn.net/qq_42734759/article/details/90021249

 

posted on   wangzy-Zj  阅读(2156)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示