关于我们

质量为本、客户为根、勇于拼搏、务实创新

< 返回新闻公共列表

解决 CentOS 修改 SSH 端口出错 error: Bind to port 1024 on 0.0.0.0 failed: Permission denied.

发布时间:2022/11/17 15:18:08
香港云服务器

VPS 上修改完 sshd_config 后(CentOS 7 系统),在操作 service sshd restart 重启 SSH 服务时,提示错误:

Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.

运行 journalctl -xe 查看错误日志如下:

-- Unit sshd.service has begun starting up.sshd[12291]: error: Bind to port 1024 on 0.0.0.0 failed: Permission denied.sshd[12291]: error: Bind to port 1024 on :: failed: Permission denied.sshd[12291]: fatal: Cannot bind any address.systemd[1]: sshd.service: main process exited, code=exited, status=255/n/a
systemd[1]: Failed to start OpenSSH server daemon.

这个问题是由于 selinux 引起的,需要修改 selinux 中的 SSH 端口。

二、解决办法

解决办法就是修改 selinux 中的 SSH 端口,解决步骤如下:

1、安装修改工具

yum -y install policycoreutils-python

2、查看 selinux 中的 SSH 端口(输出默认的端口 22)

semanage port -l | grep ssh

3、新增目标端口

semanage port -a -t ssh_port_t -p tcp 1024

4、重启 SSH 服务

service sshd restart

这样就可以重启 SSH 服务成功了,SSH 端口也就修改成功了。