我尝试安装这个 OpenSSH 包在 Windows Server 2008 R2 上。我应用了所有步骤(防火墙除外),并且全部成功通过。
当我尝试此命令时
网络启动 sshd
我收到此错误:
SSHD 服务正在启动。 SSHD 服务无法启动。
发生系统错误。
发生系统错误 1067。
该进程意外终止。
问题可能出在哪里?我找不到任何日志文件。Windows 事件查看器中的安全性仅显示:
The SSHD service terminated unexpectedly. It has done this 2 time(s).
在调试模式下运行时我得到以下信息:
--
debug2: load_server_config: filename C:\Users\Administrator\Downloads\OpenSSH-Win32\OpenSSH-Win32/sshd_config
debug2: parse_server_config: config C:\Users\Administrator\Downloads\OpenSSH-Win32\OpenSSH-Win32/sshd_config len 256
debug3: C:\Users\Administrator\Downloads\OpenSSH-Win32\OpenSSH-Win32/sshd_config:50 setting AuthorizedKeysFile .ssh/authorized_keys
debug3: C:\Users\Administrator\Downloads\OpenSSH-Win32\OpenSSH-Win32/sshd_config:115 setting Subsystem sftp /usr/libexec/sftp-server
debug3: C:\Users\Administrator\Downloads\OpenSSH-Win32\OpenSSH-Win32/sshd_config:123 setting PubkeyAcceptedKeyTypes +ssh-dss,ecdsa-sha2-nistp256
debug1: sshd version OpenSSH_7.1, OpenSSL 1.0.2d 9 Jul 2015
[Build Nov 9 2015 22:18:33]
debug3: getpwnam: username [sshd]
debug3: getpwnam: system dir [C:\Windows\system32]
debug3: getpwnam: shell path [C:\Windows\system32\cmd.exe]
debug1: _open() returned error, errno [2]
debug1: key_load_private: No such file or directory
debug1: _open() returned error, errno [2]
debug1: key_load_public: No such file or directory
Could not load host key: ssh_host_rsa_key
debug1: _open() returned error, errno [2]
debug1: key_load_private: No such file or directory
debug1: _open() returned error, errno [2]
debug1: key_load_public: No such file or directory
Could not load host key: ssh_host_dsa_key
debug1: _open() returned error, errno [2]
debug1: key_load_private: No such file or directory
debug1: _open() returned error, errno [2]
debug1: key_load_public: No such file or directory
Could not load host key: ssh_host_ecdsa_key
debug1: _open() returned error, errno [2]
debug1: key_load_private: No such file or directory
debug1: _open() returned error, errno [2]
debug1: key_load_public: No such file or directory
Could not load host key: ssh_host_ed25519_key
Disabling protocol version 2. Could not load host key
sshd: no hostkeys available -- exiting.
--
您可以在下面查看有关 XML 的更多详细信息。
笔记:
- 由于防火墙没有运行,我跳过了防火墙步骤。
- 看来我已成功生成密钥(没有错误,并且在
C:\Users\Administrator\.ssh
文件夹中看到两个文件:id_rsa 和 id_rsa.pub - 请参阅下面的输出) - 此主机上未安装防病毒软件
- 我尝试安装 32 位和 64 位软件包(两者出现同样的错误)。
- 我的机器是 64 位的,运行在 VMware 上。
- 我使用“本地系统帐户”以管理员身份安装它
这些是来自事件查看器的 XML 详细信息:
Log Name: System
Source: Service Control Manager
Date: 12/25/2015 12:17:53 PM
Event ID: 7034
Task Category: None
Level: Error
Keywords: Classic
User: N/A
Computer: WINSXXX
Description:
The SSHD service terminated unexpectedly. It has done this 2 time(s).
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Service Control Manager" Guid="{555908d1-a6d7-4695-8e1e-26931d2012f4}" EventSourceName="Service Control Manager" />
<EventID Qualifiers="49152">7034</EventID>
<Version>0</Version>
<Level>2</Level>
<Task>0</Task>
<Opcode>0</Opcode>
<Keywords>0x8080000000000000</Keywords>
<TimeCreated SystemTime="2015-12-25T10:17:53.073482000Z" />
<EventRecordID>20007</EventRecordID>
<Correlation />
<Execution ProcessID="468" ThreadID="4180" />
<Channel>System</Channel>
<Computer>WINSXXX</Computer>
<Security />
</System>
<EventData>
<Data Name="param1">SSHD</Data>
<Data Name="param2">2</Data>
</EventData>
</Event>
生成密钥的输出:
C:\Users\Administrator>C:\Users\Administrator\Downloads\OpenSSH-Win32\OpenSSH-Win32\ssh-keygen.exe
Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\Administrator/.ssh/id_rsa):
C:\Users\Administrator/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\Administrator/.ssh/id_rsa.
Your public key has been saved in C:\Users\Administrator/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:POHEtRE0YZGfFqcxjkt8x9znhJsm+MvCuhFCUR9bYxg Administrator@WINSXXX
The key's randomart image is:
+---[RSA 2048]----+
| ....EB+ |
| o +oO+.. |
| . +.++ X o |
| . + .+ B = +|
| . S. = . =.|
| . oo . + .|
| .. . o |
| .o.. |
| oo .o. |
+----[SHA256]-----+
C:\用户\管理员>
答案1
答案2
按照步骤 5 和 6 操作后,我能够启动 sshd 服务说明
设置 SSH 主机密钥(这将生成 sshd 启动时所需的所有“主机”密钥)
- .\ssh-keygen.exe -A
安全 SSH 主机密钥(可选)
- 启动服务 ssh 代理
- 下载 psexec这里
- 以 SYSTEM 身份启动 cmd.exe - psexec.exe -i -s cmd.exe
- 在上面的 cmd.exe 中注册主机密钥
- ssh-添加 ssh_host_dsa_key
- ssh-添加 ssh_host_rsa_key
- ssh-添加 ssh_host_ecdsa_key
- ssh-添加 ssh_host_ed25519_key
答案3
答案4
下载最新OpenSSH 存储库并运行文件.\FixHostFilePermissions.ps1
。对所有问题回答“是”。