修改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
分类:
Linux运维
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 地球OL攻略 —— 某应届生求职总结
· 提示词工程——AI应用必不可少的技术
· Open-Sora 2.0 重磅开源!
· 周边上新:园子的第一款马克杯温暖上架