Linux系统下SSH服务启动失败故障处理

Posted jks212454

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux系统下SSH服务启动失败故障处理相关的知识,希望对你有一定的参考价值。

Linux系统下SSH服务启动失败故障处理

一、系统版本

[root@localhost ~]# cat /etc/os-release 
NAME="CentOS Linux"
VERSION="7 (Core)"
ID="centos"
ID_LIKE="rhel fedora"
VERSION_ID="7"
PRETTY_NAME="CentOS Linux 7 (Core)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:centos:centos:7"
HOME_URL="https://www.centos.org/"
BUG_REPORT_URL="https://bugs.centos.org/"

CENTOS_MANTISBT_PROJECT="CentOS-7"
CENTOS_MANTISBT_PROJECT_VERSION="7"
REDHAT_SUPPORT_PRODUCT="centos"
REDHAT_SUPPORT_PRODUCT_VERSION="7"

二、报错状态

[root@localhost ~]# systemctl status sshd
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: activating (auto-restart) (Result: exit-code) since Fri 2022-02-04 04:36:19 CST; 38s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
  Process: 21131 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=1/FAILURE)
 Main PID: 21131 (code=exited, status=1/FAILURE)

Feb 04 04:36:19 localhost.localdomain sshd[21131]: Permissions 0640 for '/etc/ssh/ssh_host_ed25519_key' ...en.
Feb 04 04:36:19 localhost.localdomain sshd[21131]: It is required that your private key files are NOT ac...rs.
Feb 04 04:36:19 localhost.localdomain sshd[21131]: This private key will be ignored.
Feb 04 04:36:19 localhost.localdomain sshd[21131]: key_load_private: bad permissions
Feb 04 04:36:19 localhost.localdomain sshd[21131]: Could not load host key: /etc/ssh/ssh_host_ed25519_key
Feb 04 04:36:19 localhost.localdomain sshd[21131]: sshd: no hostkeys available -- exiting.
Feb 04 04:36:19 localhost.localdomain systemd[1]: sshd.service: main process exited, code=exited, status...URE
Feb 04 04:36:19 localhost.localdomain systemd[1]: Failed to start OpenSSH server daemon.
Feb 04 04:36:19 localhost.localdomain systemd[1]: Unit sshd.service entered failed state.
Feb 04 04:36:19 localhost.localdomain systemd[1]: sshd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.

三、处理方法

[root@localhost ssh]#chmod 600 /etc/ssh/ssh_host_ed25519_key
[root@localhost ssh]# systemctl restart sshd

四、查看服务状态

[root@localhost ssh]# systemctl status sshd
● sshd.service - OpenSSH server daemon
   Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2022-02-04 05:18:48 CST; 1min 39s ago
     Docs: man:sshd(8)
           man:sshd_config(5)
 Main PID: 22158 (sshd)
    Tasks: 1
   CGroup: /system.slice/sshd.service
           └─22158 /usr/sbin/sshd -D

Feb 04 05:18:48 localhost.localdomain sshd[22158]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Feb 04 05:18:48 localhost.localdomain sshd[22158]: @         WARNING: UNPROTECTED PRIVATE KEY FILE!          @
Feb 04 05:18:48 localhost.localdomain sshd[22158]: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
Feb 04 05:18:48 localhost.localdomain sshd[22158]: Permissions 0640 for '/etc/ssh/ssh_host_ecdsa_key' are too open.
Feb 04 05:18:48 localhost.localdomain sshd[22158]: It is required that your private key files are NOT accessible by others.
Feb 04 05:18:48 localhost.localdomain sshd[22158]: This private key will be ignored.
Feb 04 05:18:48 localhost.localdomain sshd[22158]: key_load_private: bad permissions
Feb 04 05:18:48 localhost.localdomain sshd[22158]: Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Feb 04 05:18:48 localhost.localdomain sshd[22158]: Server listening on :: port 22.
Feb 04 05:18:48 localhost.localdomain systemd[1]: Started OpenSSH server daemon.
[root@localhost ssh]# 


以上是关于Linux系统下SSH服务启动失败故障处理的主要内容,如果未能解决你的问题,请参考以下文章

怎么查看linux重启ssh进程失败原因

linux系统下如何从后台启动进程?

记录一次linux下微服务文件上传失败

Linux下ssh连接缓慢的处理方法

Harbor故障篇:服务启动失败问题处理记录

Linux故障处理系统启动类故障