【原创】WSL Ubuntu 运行 sshd 缺少证书报错

概览

1、简介

在 Windows 的 WSL Ubuntu 18.04 中,已经自带了 openssh-server 程序,但是 openssh-server 没有自动启动,也没有正确匹配。所以在第一次运行的时候出现了报错。

本文分享运行 sshd 服务器报证书错误的解决方法。

2、相关环境

Windows 10 pro 1909
WSL Ubuntu 18.04
ssh 7.6

问题描述

在 Windows 的 WSL Ubuntu 18.04 中运行 ssh 服务器的时候,出现报错。

jiangzl@DESKTOP-3CSI1G5:/var/log$ sudo service ssh start
* Starting OpenBSD Secure Shell server 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
                                                                                                                                                                                                                             [ OK ]        

如下图所示:

问题原因

出现这个问题是因为 openssh-server 没有正确配置。

解决方法

1、重新配置 openssh-server 

执行如下命令重新配置 openssh-server,这个过程中会自动生成证书文件。

$ sudo dpkg-reconfigure openssh-server

如下图所示:

2、重启 sshd 服务

重新配置了 openssh-server 后,需要执行如下命令重试 sshd 服务。

$ sudo service ssh restart

示例:

jiangzl@DESKTOP-3CSI1G5:/var/log$ sudo service ssh start
* Retarting OpenBSD Secure Shell server sshd                                                                                                                                                                                 [ OK ]   

附录

参考:

https://askubuntu.com/questions/600584/error-could-not-load-host-key-when-trying-to-recreate-ssh-host-keys

You may also like...

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注