Windows 本机 OpenSSH 和 git 无法与服务器协商密码

Windows native OpenSSH and git failing to negotiate cipher with server

我正在尝试将 Windows 本机 OpenSSH 与 git 结合使用。我按照 Posh Security 了解如何配置所有内容。我还将此添加到我的 C:\Users\UserID\.ssh\config 文件

Ciphers aes256-cbc,aes192-cbc,aes128-cbc

但是,我无法让它工作。我收到以下错误消息。

无法与 129.176.176.111 端口 22 协商:未找到匹配的密码。他们的报价:aes256-cbc,aes192-cbc,aes128-cbc

这是尝试连接到服务器的调试输出。

OpenSSH_for_Windows_7.7p1, LibreSSL 2.6.5
debug1: Reading configuration data C:\Users\M112581/.ssh/config
debug3: Failed to open file:C:/ProgramData/ssh/ssh_config error:2
debug2: resolving "tfs.mayo.edu" port 22
debug2: ssh_connect_direct: needpriv 0
debug1: Connecting to tfs.mayo.edu [129.176.176.111] port 22.
debug1: Connection established.
debug1: identity file C:\Users\M112581/.ssh/id_rsa type 0
debug3: Failed to open file:C:/Users/M112581/.ssh/id_rsa-cert error:2
debug3: Failed to open file:C:/Users/M112581/.ssh/id_rsa-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\M112581/.ssh/id_rsa-cert type -1
debug3: Failed to open file:C:/Users/M112581/.ssh/id_dsa error:2
debug3: Failed to open file:C:/Users/M112581/.ssh/id_dsa.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\M112581/.ssh/id_dsa type -1
debug3: Failed to open file:C:/Users/M112581/.ssh/id_dsa-cert error:2
debug3: Failed to open file:C:/Users/M112581/.ssh/id_dsa-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\M112581/.ssh/id_dsa-cert type -1
debug3: Failed to open file:C:/Users/M112581/.ssh/id_ecdsa error:2
debug3: Failed to open file:C:/Users/M112581/.ssh/id_ecdsa.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\M112581/.ssh/id_ecdsa type -1
debug3: Failed to open file:C:/Users/M112581/.ssh/id_ecdsa-cert error:2
debug3: Failed to open file:C:/Users/M112581/.ssh/id_ecdsa-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\M112581/.ssh/id_ecdsa-cert type -1
debug3: Failed to open file:C:/Users/M112581/.ssh/id_ed25519 error:2
debug3: Failed to open file:C:/Users/M112581/.ssh/id_ed25519.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\M112581/.ssh/id_ed25519 type -1
debug3: Failed to open file:C:/Users/M112581/.ssh/id_ed25519-cert error:2
debug3: Failed to open file:C:/Users/M112581/.ssh/id_ed25519-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\M112581/.ssh/id_ed25519-cert type -1
debug3: Failed to open file:C:/Users/M112581/.ssh/id_xmss error:2
debug3: Failed to open file:C:/Users/M112581/.ssh/id_xmss.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\M112581/.ssh/id_xmss type -1
debug3: Failed to open file:C:/Users/M112581/.ssh/id_xmss-cert error:2
debug3: Failed to open file:C:/Users/M112581/.ssh/id_xmss-cert.pub error:2
debug1: key_load_public: No such file or directory
debug1: identity file C:\Users\M112581/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version SSHBlackbox.10
debug1: no match: SSHBlackbox.10
debug2: fd 3 setting O_NONBLOCK
debug1: Authenticating to tfs.mayo.edu:22 as 'm112581'
debug3: hostkeys_foreach: reading file "C:\Users\M112581/.ssh/known_hosts"
debug3: record_hostkey: found key type RSA in file C:\Users\M112581/.ssh/known_hosts:6
debug3: load_hostkeys: loaded 1 keys from tfs.mayo.edu
debug3: Failed to open file:C:/Users/M112581/.ssh/known_hosts2 error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts error:2
debug3: Failed to open file:C:/ProgramData/ssh/ssh_known_hosts2 error:2
debug3: order_hostkeyalgs: prefer hostkeyalgs: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa
debug3: send packet: type 20
debug1: SSH2_MSG_KEXINIT sent
debug3: receive packet: type 20
debug1: SSH2_MSG_KEXINIT received
debug2: local client KEXINIT proposal
debug2: KEX algorithms: curve25519-sha256,curve25519-sha256@libssh.org,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group16-sha512,diffie-hellman-group18-sha512,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha256,diffie-hellman-group14-sha1,ext-info-c
debug2: host key algorithms: ssh-rsa-cert-v01@openssh.com,rsa-sha2-512,rsa-sha2-256,ssh-rsa,ecdsa-sha2-nistp256-cert-v01@openssh.com,ecdsa-sha2-nistp384-cert-v01@openssh.com,ecdsa-sha2-nistp521-cert-v01@openssh.com,ssh-ed25519-cert-v01@openssh.com,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519
debug2: ciphers ctos: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: ciphers stoc: chacha20-poly1305@openssh.com,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@openssh.com,aes256-gcm@openssh.com
debug2: MACs ctos: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: MACs stoc: umac-64-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-sha2-512-etm@openssh.com,hmac-sha1-etm@openssh.com,umac-64@openssh.com,umac-128@openssh.com,hmac-sha2-256,hmac-sha2-512,hmac-sha1
debug2: compression ctos: none
debug2: compression stoc: none
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug2: peer server KEXINIT proposal
debug2: KEX algorithms: diffie-hellman-group1-sha1,diffie-hellman-group14-sha1
debug2: host key algorithms: ssh-rsa
debug2: ciphers ctos: aes256-cbc,aes192-cbc,aes128-cbc
debug2: ciphers stoc: aes256-cbc,aes192-cbc,aes128-cbc
debug2: MACs ctos: hmac-sha2-256,hmac-sha2-512
debug2: MACs stoc: hmac-sha2-256,hmac-sha2-512
debug2: compression ctos: none,zlib,zlib@openssh.com
debug2: compression stoc: none,zlib,zlib@openssh.com
debug2: languages ctos:
debug2: languages stoc:
debug2: first_kex_follows 0
debug2: reserved 0
debug1: kex: algorithm: diffie-hellman-group14-sha1
debug1: kex: host key algorithm: ssh-rsa
Unable to negotiate with 129.176.176.111 port 22: no matching cipher found. Their offer: aes256-cbc,aes192-cbc,aes128-cbc

当我将 -c 添加到提供的密码之一(例如 aes256-cbc)时,它能够协商。

ssh -c aes256-cbc 129.176.176.111
debug1: Authentication succeeded (publickey).
Authenticated to tfs.mayo.edu ([129.176.176.111]:22)

谁能帮我弄清楚为什么在使用 git 时连接失败?为什么我的 C:\Users\UserID\.ssh\config 文件中的密码之一没有被使用?

.ssh/config 文件中的指令需要在 Host 块中,因此您可能需要这样写:

Host tfs.mayo.edu
    Ciphers chacha20-poly1305@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr,aes256-cbc,aes192-cbc,aes128-cbc

请注意,已知您使用的密钥交换算法和密码是不安全的,OpenSSH 将来可能会放弃对它们的支持。由于它们不安全,您不想将自己限制在那些密码上,而是将它们放在以更安全的密码开头的列表的末尾。这样,如果服务器升级为支持更好的密码,您会自动使用它们,而不是继续使用不安全的密码。

您应该联系您的管理员,让他们将 TFS 升级到没有这些漏洞的固定版本。