启动sshd时,报“Could not load host key”错
原文发表于cu:2016-05-24
现象:启动sshd服务时,虽看似服务启动成功,但客户端并不能连接上sshd服务器端。如下:
[root@aefe8007a17d ~]# /usr/sbin/sshd
Could not load host key: /etc/ssh/ssh_host_rsa_key
Could not load host key: /etc/ssh/ssh_host_ecdsa_key
Could not load host key: /etc/ssh/ssh_host_ed25519_key
原因:
1. 从提示信息看是sshd守护进程不能加载主机密钥文件,因为找不到这些密钥文件(配置文件/etc/ssh/sshd_config中已定义密钥文件名与路径);
2. 一般openssh服务正常安装后,主机会自动生成相应的主机密钥文件,但这里因未知原因并没有完成这一步动作,导致无法远程ssh连接。
ps:检查密钥文件是否存在(还有一种现象为:密钥文件存在,但文件大小为0):
[root@aefe8007a17d ~]# ll /etc/ssh/
total 252
-rw-r--r-- 1 root root 242153 Mar 21 22:18 moduli
-rw-r--r-- 1 root root 2208 Mar 21 22:18 ssh_config
-rw------- 1 root root 4361 Mar 21 22:18 sshd_config
解决方案,重新生成主机密钥文件:
1. 生成rsa_key (-t表示生成的密钥所使用的加密类型;-f项后接要生成的密钥文件名);
[root@aefe8007a17d ~]# ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
Generating public/private rsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /etc/ssh/ssh_host_rsa_key.
Your public key has been saved in /etc/ssh/ssh_host_rsa_key.pub.
The key fingerprint is:
5e:2d:19:51:b1:e3:e0:60:65:53:e4:14:f8:d8:38:af root@aefe8007a17d
The key's randomart image is:
+--[ RSA 2048]----+
| ==Bo |
| o.= . |
| o o=+ |
| . o+*o. |
| S =oo |
| . . .. |
| . . |
| E |
| |
+-----------------+
[root@aefe8007a17d ~]# ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
2. 生成ecdsa_key;
[root@aefe8007a17d ~]# ssh-keygen -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key
3. 生成ed25519_key。
[root@aefe8007a17d ~]# ssh-keygen -t ed25519 -f /etc/ssh/ssh_host_ed25519_key
验证:
1. 再次检查密钥文件是否存在且合规,可以看到已生成相应主机密钥文件(实际上主机密钥文件为私钥,.pub文件为公钥):
[root@aefe8007a17d ~]# ll /etc/ssh/
total 276
-rw-r--r-- 1 root root 242153 Mar 21 22:18 moduli
-rw-r--r-- 1 root root 2208 Mar 21 22:18 ssh_config
-rw------- 1 root root 227 May 22 16:48 ssh_host_ecdsa_key
-rw-r--r-- 1 root root 179 May 22 16:48 ssh_host_ecdsa_key.pub
-rw------- 1 root root 411 May 22 16:48 ssh_host_ed25519_key
-rw-r--r-- 1 root root 99 May 22 16:48 ssh_host_ed25519_key.pub
-rw------- 1 root root 1679 May 22 16:48 ssh_host_rsa_key
-rw-r--r-- 1 root root 399 May 22 16:48 ssh_host_rsa_key.pub
-rw------- 1 root root 4361 Mar 21 22:18 sshd_config
2. 此时客户端可ssh连接上sshd服务器端:
[root@localhost ~]# ssh 172.17.0.2
The authenticity of host '172.17.0.2 (172.17.0.2)' can't be established.
ECDSA key fingerprint is 37:2a:69:46:c4:bd:92:b2:43:b4:cc:42:41:8e:12:2e.
Are you sure you want to continue connecting (yes/no)?
启动sshd时,报“Could not load host key”错的更多相关文章
- sshd 启动后 出现:Could not load host key: /etc/ssh/ssh_host_rsa_key
今天在启动sshd时,出现了如下问题,导致客户端不能成功连接服务端,不能建立ssh连接: 有两个提示 Could not load host key: /etc/ssh/ssh_host_rsa_ke ...
- [转] Linux有问必答:如何修复“sshd error: could not load host key”
编译自:http://ask.xmodulo.com/sshd-error-could-not-load-host-key.html作者: GOLinux 本文地址:https://linux.cn/ ...
- 如何修复“sshd error: could not load host key”
问题:当我尝试SSH到一台远程服务器时,SSH客户端登陆失败并提示“Connection closed by X.X.X.X”.在SSH服务器那端,我看到这样的错误消息:“sshd error: co ...
- sshd启动报错Could not load host key
~ # /usr/sbin/sshd Could not load host key: /etc/ssh/ssh_host_rsa_key Could not load host key: /etc/ ...
- 启动eclipse时出现“Failed to load the JNI shared library jvm.dll”错误及解决-及eclipse版本查看
启动eclipse时出现“Failed to load the JNI shared library jvm.dll”错误及解决-及eclipse版本查看 学习了:https://www.cnblog ...
- xvfb启动PyQt4程序报Unable to load library icui18n错误
xvfb启动PyQt4程序报如下错误: Unable to load library icui18n "Cannot load library icui18n: (libicui18n.so ...
- SSH 登录时出现如下错误:Host key verification failed
注意:本文相关 Linux 配置及说明已在 CentOS 6.5 64 位操作系统中进行过测试.其它类型及版本操作系统配置可能有所差异,具体情况请参阅相应操作系统官方文档. 问题描述 使用 SS ...
- 阿里云服务器教程–SSH 登录时出现如下错误:Host key verification failed
注意:本文相关 Linux 配置及说明已在 CentOS 6.5 64 位操作系统中进行过测试.其它类型及版本操作系统配置可能有所差异,具体情况请参阅相应操作系统官方文档. 问题描述 使用 SSH 登 ...
- 启动eclipse时出现“Failed to load the JNI shared library jvm.dll”错误及解决
昨晚安装另一个版本的eclipse,启动时出现了"Failed to load the JNI shared library jvm.dll"错误: 1.刚开始以为是因为当时没有将 ...
随机推荐
- VMware虚拟机安装Centos7图文教程
CentOS 是一个工业标准的 Linux 发行版,是红帽企业版 Linux 的衍生版本.你安装完后马上就可以使用,但是为了更好地使用你的系统,你需要进行一些升级.安装新的软件包.配置特定服务和应用程 ...
- Oracle 执行计划的查看方式
访问数据的方法:一.访问表的方法:1.全表扫描,2.ROWID扫描 二.访问索引的方法:1.索引唯一性扫描,2.索引范围扫描,3.索引全扫 ...
- Hadoop相关笔记
一. Zookeeper( 分布式协调服务框架 ) 1. Zookeeper概述和集群搭建: (1) Zookeeper概述: Zookeeper 是一个分布式 ...
- shell习题第3题:统计内存大小
[题目要求] 写一个脚本计算一下linux系统所有进程占用内存的大小的和 [核心要点] ps命令用法 for循环 加法运算 [脚本] #!/bin/bash for n in `ps aux | gr ...
- flAbsPath on /var/lib/dpkg/status failed 解决 Cydia 红字
越狱之后抹掉所有数据,然后再使用 doubleH3lix 越狱成功后,打开 Cydia 会提示如下错误: flAbsPath on /var/lib/dpkg/status failed - real ...
- Mongodb安装步骤(基于mongodb-3.2.12-tar.gz)
1. 下载mongodb数据库:https://www.mongodb.com/download-center#community 2. 加压tar.gz压缩包,把解压文件拷贝到程序目录即可 3. 创 ...
- [示例] Firemonkey 面包屑导航
原码下载:[示例]Firemonkey面包屑导航_Aone.zip 效果:(以下效果不用写一行代码)
- 百度地图热力图--批量地址转换应用(基于百度api)
需求:把外卖订餐地址做个用户分布热力图 思路分析:第一步去百度地图api开放平台找例子 http://lbsyun.baidu.com/jsdemo.htm#c1_15 首先从百度API的demo例子 ...
- 大数据学习--day17(Map--HashMap--TreeMap、红黑树)
Map--HashMap--TreeMap--红黑树 Map:三种遍历方式 HashMap:拉链法.用哈希函数计算出int值. 用桶的思想去存储元素.桶里的元素用链表串起来,之后长了的话转红黑树. T ...
- docker 容器模式下部署mysql 主从复制
1.计划用两台host来部署,分别部署一台 mysql,一主一从,2.配置好主从mysql配置文件,更改文件名即可[client]port = 3306socket = /var/run/mysqld ...