sshd.service 作业失败,因为控制进程退出并显示错误代码。
> -- Unit sshd.service has begun starting up. ctl sshd[4845]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use. ctl
> sshd[4845]: error: Bind to port 22 on :: failed: Address already in
> use. ctl sshd[4845]: fatal: Cannot bind any address. ctl systemd[1]:
> sshd.service: main process exited, code=exited, status=255/n/a ctl
> audispd[584]: node=servername type=CRYPTO_KEY_USER
> msg=audit(xxx.xx:yyyy): pid=4845 uid=0 auid=4294967295 ses=4294967295
> subj=system_u:syste Mar 08 12:07:00 ctl systemd[1]: Failed to start
> OpenSSH server daemon.
> -- Subject: Unit sshd.service has failed
> -- Defined-By: systemd
> -- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
> -- Unit sshd.service has failed.
> -- The result is failed. Mar 08 12:07:00 ctl audispd[584]: node=servername type=CRYPTO_KEY_USER msg=audit(1583669220.759:5500):
> pid=4845 uid=0 auid=4294967295 ses=4294967295 subj=system_u:syste Mar
> 08 12:07:00 ctl systemd[1]: Unit sshd.service entered failed state.
> Mar 08 12:07:00 ctl audispd[584]: node=servername type=CRYPTO_KEY_USER
> msg=audit(1583669220.759:5501): pid=4845 uid=0 auid=4294967295
> ses=4294967295 subj=system_u:syste Mar 08 12:07:00 ctl systemd[1]:
> sshd.service failed. Mar 08 12:07:00 ctl audispd[584]: node=servername
> type=SERVICE_START msg=audit(1583669220.760:5502): pid=1 uid=0
> auid=4294967295 ses=4294967295 subj=system_u:system_r:i [root@server
> conf]# :system_r:init_t:s0 msg='unit=sshd comm="systemd"
> exe="/usr/lib/systemd/systemd" hostname=? addr=? terminal=?
> res=failed' M
我尝试检查监听端口 22 的服务
netstat -tunlp | grep 22
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1023/sshd
tcp6 0 0 :::22 :::* LISTEN 1023/sshd
我看到 tcp6 和 tcp 正在侦听端口 22,并尝试禁用 ipv6
引用的这并禁用 ipv6
对 /etc/sysctl.conf 进行了更改
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
还编辑了 grub
/etc/default/grub
并添加了ipv6.disable=1
即使重新启动后,我也无法在端口 22 上禁用 tcp6。我还可以检查什么来解决 sshd 启动问题
正在运行的进程列表
ps -ef | grep sshd
root 1023 1 0 13:15 ? 00:00:00 /usr/share/centrifydc/sbin/sshd -D
root 1899 1023 0 13:15 ? 00:00:00 sshd: ec2-user [priv]
root 1900 1023 0 13:15 ? 00:00:00 sshd: ec2-user [priv]
ec2-user 1994 1900 0 13:15 ? 00:00:00 sshd: ec2-user
ec2-user 1996 1899 0 13:15 ? 00:00:00 sshd: ec2-user@pts/0
root 3282 3268 0 13:22 pts/0 00:00:00 grep --color=auto sshd
一旦我杀死了 Centrify 进程,我就能够启动 sshd 进程。
谢谢内特
答案1
正在运行的进程列表
ps -ef | grep sshd
root 1023 1 0 13:15 ? 00:00:00 /usr/share/centrifydc/sbin/sshd -D
root 1899 1023 0 13:15 ? 00:00:00 sshd: ec2-user [priv]
root 1900 1023 0 13:15 ? 00:00:00 sshd: ec2-user [priv]
ec2-user 1994 1900 0 13:15 ? 00:00:00 sshd: ec2-user
ec2-user 1996 1899 0 13:15 ? 00:00:00 sshd: ec2-user@pts/0
root 3282 3268 0 13:22 pts/0 00:00:00 grep --color=auto sshd
一旦我杀死了 Centrify 进程,我就能够启动 sshd 进程。感谢 Ulrich 和 Jeff 帮助解决问题。