三分之二的客户端使用 ssh 密钥失败

三分之二的客户端使用 ssh 密钥失败

我在从 Windows 10 Pro 笔记本电脑建立到远程 Linux 计算机的连接时遇到问题。我通常使用无密码 SSH 连接,这是我第一次遇到此问题:我不知道如何解决。

我收到了一台运行 Linux 的机器的私钥id_rsa(OpenSSH 私钥)。

在 Windows 上我得到了这个:

  • 使用 Termius 客户端时无法建立连接,这在数十台主机上从未给我带来任何问题;
  • ssh未使用Windows Subsystem for Linux (WSL) 上的 bash 终端建立连接。
  • 使用 Windows 终端建立连接 版本:1.14.1962.0
  • 我能够使用 Visual Studio Code 与远程服务器建立无密码 SSH 连接。

当我ssh在 WSL 上使用时,收到以下消息:

$-> file id_rsa
id_rsa: OpenSSH private key

$-> file id_rsa.pub
id_rsa.pub: OpenSSH RSA public key

$-> ssh-keygen -l -f id_rsa
3072 SHA256:REMOVED user@remote-machine (RSA)

$-> ssh-keygen -l -f id_rsa.pub
3072 SHA256:REMOVED user@remote-machine (RSA)

$-> ssh [email protected] -v -i id_rsa
OpenSSH_8.2p1 Ubuntu-4ubuntu0.4, OpenSSL 1.1.1f  31 Mar 2020
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 21: Applying options for 111.222.333.444
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: include /etc/ssh/ssh_config.d/*.conf matched no files
debug1: /etc/ssh/ssh_config line 21: Applying options for *
debug1: Connecting to 111.222.333.444[111.222.333.444] port 22.
debug1: Connection established.
debug1: identity file id_rsa type 0
debug1: identity file id_rsa-cert type -1
debug1: identity file /home/user/.ssh/id_rsa type 0
debug1: identity file /home/user/.ssh/id_rsa-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.2p1 Ubuntu-4ubuntu0.4
debug1: Remote protocol version 2.0, remote software version OpenSSH_8.2p1 Ubuntu-4ubuntu0.3
debug1: match: OpenSSH_8.2p1 Ubuntu-4ubuntu0.3 pat OpenSSH* compat 0x04000000
debug1: Authenticating to 111.222.333.444:22 as 'user'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: curve25519-sha256
debug1: kex: host key algorithm: ecdsa-sha2-nistp256
debug1: kex: server->client cipher: [email protected] MAC: <implicit> compression: none
debug1: kex: client->server cipher: [email protected] MAC: <implicit> compression: none
debug1: expecting SSH2_MSG_KEX_ECDH_REPLY
debug1: Server host key: ecdsa-sha2-nistp256 SHA256:oGg/GNvtgLO8YHaoU+rKdzDo8sTqY9OCwso9crQD7Ac
debug1: Host '111.222.333.444' is known and matches the ECDSA host key.
debug1: Found key in /home/user/.ssh/known_hosts:5
debug1: rekey out after 134217728 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: SSH2_MSG_NEWKEYS received
debug1: rekey in after 134217728 blocks
debug1: Will attempt key: id_rsa RSA SHA256:[REMOVED]
debug1: Will attempt key: /home/user/.ssh/id_rsa RSA SHA256:xtXTMKUvn01g28j5YtxT7Y/Gz/Coz4uuyNIjCgmeJBg explicit
debug1: SSH2_MSG_EXT_INFO received
debug1: kex_input_ext_info: server-sig-algs=<ssh-ed25519,[email protected],ssh-rsa,rsa-sha2-256,rsa-sha2-512,ssh-dss,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,[email protected]>
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentications that can continue: publickey
debug1: Next authentication method: publickey
debug1: Offering public key: id_rsa RSA SHA256:[REMOVED]
debug1: Server accepts key: id_rsa RSA SHA256:[REMOVED] explicit
Load key "id_rsa": invalid format
debug1: Offering public key: /home/user/.ssh/id_rsa RSA SHA256:[REMOVED] explicit
debug1: Server accepts key: /home/user/.ssh/id_rsa RSA SHA256:[REMOVED] explicit
Load key "/home/user/.ssh/id_rsa": invalid format
debug1: No more authentication methods to try.
[email protected]: Permission denied (publickey).

唯一的错误消息是invalid format,但密钥已使用 ssh-keygen 生成并被 Windows 终端接受。此外,在同一个 WSL bash 上,filessh-keygen检查都通过。

我也尝试在本地主机和远程主机上生成其他 ssh 密钥,但仍然得到这种连接“模式”。

有谁可以提供一些线索,知道应该看什么吗?

相关内容