修改ssh端口重启服务报错error: Bind to port 8822 on :: failed: Permission denied

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


查了一下,是selinux的问题,最简单的办法是关了selinux。
但是,想要开启selinux,并修改sshd的端口,需要把要添加的sshd服务端口在selinux上注册。

- 安装semanage

 

 
  1. yum -y install policycoreutils-python

- 查看selinux中sshd当前的端口

 
  1. [root@BabyishRecent-VM ~]# semanage port -l | grep ssh
  2. ssh_port_t tcp 22

- 在selinux中添加端口

 

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

 

- 重启sshd服务

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

- 防火墙放行修改后的端口

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

 

转载于:http://flyfish.im/studynotes/1041.html

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值