【Centos】sshd 无法启动(解决问题篇,附问题排查思路和解决方法)

前言

美好的一天,从帮人运维开始

问题

朋友报过来的问题如下:

[root@VM-0-16-centos /]# systemctl start sshd
Error getting authority: Error initializing authority: Could not connect: No such file or directory (g-io-error-quark, 1)
Job for sshd.service failed because the control process exited with error code. See"systemctl status sshd.service" and"journal
ctl -xe" for details
[root@VM-0-16-centos /]#

解决思路和方法

Permissions 0644 for '/etc/ssh/ssh_host_xxxxx_key'are too open

然后用systemctl status sshd. service命令查看sshd的状态,

[root@VM-0-16-centos /]#systemclt status sshd.service
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: activating Cauto-restart)(Result: exit-code) since Sun 2021-89-05 09: 30: 18 CST: 12s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
   Process: 13561 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=1/FAILURE)
  Main pid: 13561 (code=exited status=1/FAIlURE)
Sep 85 89: 30: 18 VM-8-16-centos sshd[13561]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Sep B5 89: 30: 18 VM-9-16-centos sshd[13561]: Permissions 8644 for/etc/ssh/ssh_host_ed25519_key‘are too open
Sep 05 89: 30: 18 VM-0-16-centos sshd[13561]:It is required that your private key files are NoT accessible by others
Sep 05 89: 30: 18 VM-0-16-centos sshd[13561]: This private key will be ignored
Sep 85 89: 30: 18 UM-0-16-centos sshd[13561]: key_load_private: bad permissions
Sep 05 89: 30: 18 UM-0-16-centos sshd[13561]: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Sep 05 89: 30: 18 VM-8-16-centos sshd[13561]: sshd: no hostkeys available -- exiting
Sep 05 89: 30: 18 UM-0-16-centos system[1]: Failed to start OpenSSH server daemon
Sep 05 89: 30: 18 UM-0-16-centos systemd[1]: Unit sshd.service entered failed state
Sep 05 89: 36: 18 UM-0-16-centos systemd[1]: sshd.service failed
[root@VM-0-16-centos /]#

发现有一句报错是

Permissions 0644 for '/etc/ssh/ssh_host_ed25519_key' are too open

这句话就是说的是你的这个key文件的权限过高

我们把权限调整一下

chmod 600 /etc/ssh/ssh_host_ed25519_key

再然后用sshd -t检查一下,结果发现还有错,这次是说了/etc/ssh/ssh_host_rsa_key这个文件的权限过高

Permissions 0744 for '/etc/ssh/ssh_host_rsa_key' are too open

同样的修改权限

chmod 600 /etc/ssh/etc/ssh/ssh_host_rsa_key

Missing privilege separation directory: /var/empty/sshd

再然后用sshd -t检查一下,结果发现还有错,这次是说了

Missing privilege separation directory: /var/empty/sshd

 

这个报错的原因是,当我们启动sshd的时候,它会寻找“localtime”的符号链接(软链接),如果找不到,则会导致以下错误消息。

启动sshd:缺少权限分离目录:/var/empty/sshd

mkdir -p /var/empty/sshd/etc
cd /var/empty/sshd/etc/
ln -s /etc/localtime localtime

 最后再用sshd -t检查一下,发现没有问题,查看sshd的服务状态。正常运行。问题解决

总结

美好的一天,从解决问题开始,好的,这下子又水了一篇博客了。

写在后面

如果觉得有用的话,麻烦一键三支持一下攻城狮白玉并把本文分享给更多的小伙伴。你的简单支持,我的无限创作动力

 

猜你喜欢

转载自blog.csdn.net/zhh763984017/article/details/120111936