ssh-keyscan 不返回密钥

ssh-keyscan 不返回密钥

这是我的控制台的示例。我希望在那里的某个地方看到指纹,就像我对其他主机所做的那样。目前通过适用于 Linux 的 Windows 子系统使用 Ubuntu。我有一个我想要为其获取密钥的许多主机的列表。其中一些有效,有些则无效。

user@user:/homedir$ ssh-keyscan -H hostname
# hostname:22 SSH-2.0-9.99 sshlib
# hostname:22 SSH-2.0-9.99 sshlib
# hostname:22 SSH-2.0-9.99 sshlib
# hostname:22 SSH-2.0-9.99 sshlib
# hostname:22 SSH-2.0-9.99 sshlib

使用 -v 获取调试日志,输出如下所示:

debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: (no match)
debug1: no match: 9.99 sshlib

当成功的按键扫描看起来像这样:

debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: hmac-sha2-256 compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<8192<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
hostname ssh-rsa AAAAB...etc

使用客户端(FileZilla)连接到服务器成功并返回 ssh-dss 1024 主机密钥。我想使用 ssh-keyscan 获取相同的主机密钥。

来自ubuntu文档,要查找的 ssh-keyscan 默认密钥类型是 rsa,因此用户必须指定 dsa 才能获取该特定主机的 ssh-dss 密钥。

-t 类型:

         Specifies the type of the key to fetch from the scanned hosts.  The possible values
         are “rsa1” for protocol version 1 and “dsa”, “ecdsa”, “ed25519”, or “rsa” for
         protocol version 2.  Multiple values may be specified by separating them with
         commas.  The default is to fetch “rsa”, “ecdsa”, and “ed25519” keys.

因此,在一些我无法找到密钥的情况下,可以使用以下方法:

ssh-keyscan -t dsa hostname

如果你想尝试所有你可以做的:

ssh-keyscan -T 20 -t dsa, rsa1, rsa, ecdsa, ed25518 hostname

给它更长的超时时间 20 秒,因为这可能需要一段时间。对于我尝试连接的许多主机来说,这仍然不起作用,所以我仍然没有答案。

相关内容