从 Cygwin 到 Ubuntu 的 SSH 密钥交换失败

从 Cygwin 到 Ubuntu 的 SSH 密钥交换失败

我正在尝试从 Windows/Cygwin SSH 到 Ubuntu。我没有使用 PuTTY。相反,我使用 Cygwin ssh,应该是 OpenSSH。我在 Windows 机器上使用 ssh-user-config 生成密钥对:RSA1、RSA2 和 DSA。我没有在密钥上使用任何密码。当我运行:

ssh -vvv [email protected]

我得到:

OpenSSH_5.6p1, OpenSSL 0.9.8o 01 Jun 2010
debug1: Reading configuration data /c/Documents and Settings/zzzz/.ssh/config
debug2: ssh_connect: needpriv 0
debug1: Executing proxy command: exec corkscrew corporate.proxy.zzz 8080 zzzz.zzz 22
debug1: permanently_drop_suid: 101684
debug3: Not a RSA1 key file /c/Documents and Settings/zzzz/.ssh/id_rsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /c/Documents and Settings/zzzz/.ssh/id_rsa type 1
debug1: identity file /c/Documents and Settings/zzzz/.ssh/id_rsa-cert type -1
debug3: Not a RSA1 key file /c/Documents and Settings/zzzz/.ssh/id_dsa.
debug2: key_type_from_name: unknown key type '-----BEGIN'
debug3: key_read: missing keytype
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug3: key_read: missing whitespace
debug2: key_type_from_name: unknown key type '-----END'
debug3: key_read: missing keytype
debug1: identity file /c/Documents and Settings/zzzz/.ssh/id_dsa type 2
debug1: identity file /c/Documents and Settings/zzzz/.ssh/id_dsa-cert type -1
ssh_exchange_identification: Connection closed by remote host

我在 Windows 机器上使用 corkscrew 来穿越公司防火墙。我认为这与此问题无关。

如果重要的话,目标服务器是 Slicehost Ubuntu 10.04 (Lucid) LTS 实例。我假设它也在运行 OpenSSH,那么 Cygwin OpenSSH 生成的密钥不应该与 Ubuntu 兼容吗???

私钥(~/.ssh/id_rsa)如下所示:

-----BEGIN RSA PRIVATE KEY-----
MIIEpAIBAAKCAQEA0tASFawZdtNVXYg7ms6z1R2YiPcuBUgMt0loZSbmCzovuHG6
2wrU5SIiaSpPlQbsVJXjOcCzNhn8wujXo0J/RiOge7MnSmCKAaWtRc7cidh9qO13
nh8IL9TC94Cj+bPBSC5fYewc+B92WBnG2YmKRD8OxEc7KaHtchqhfsz9IzHPHKl4
r6PhIuevAymYT3YMMWF+yjmECrwIS/7nw1mSn4qUDYMU+t6dbhO+Sw/hfYvvzCMI
ILZKF5WTN7zNO5Sl1VS1BHxB0mb2Yg+BpmjQ8iEPoUuqUA+LA3+A1jVFBjrtFCoZ
1ARKO6GwE1PfFIgepuzu4msdOu4NHH+HwsZj/wIDAQABAoIBAQDSbG4gw9AHE5s5
6SnVtE08hHYlANUm4GwQ520UymcE/ed0K9FfosgujovafSlCj86F/7b3hqlbb0Ul
KFVV2KJB2H3v+ztUulgGnOD/tSPdVALaA25Knp8FX1HcysLiE9LxwZfjnlKsOHtg
JRqfOPKSfH643IDpZYAlTP+2GdbysI016ZxBajRJfl6vkd8LVqnX682LFNlQv7aQ
L/hnPZYWmwDtlFZE6ZWqex/kYQksDsqthYOf4chY8kvpLqIkquCniq7nLC3hDHSl
6peUtuoq0eoNO3G3PHbvkoMz02V15PdADZeA9yr33T+hDP2aRgFqMfBthA3lFphX
+XV8I2BBAoGBAO0IP5TocnMpyVERRBNlobBSxk66XeMCWvZPfKapeHTLZjSaIgh5
1R9WSD2jmtRTpDONSwigbniwB4Yb+nELsITI7i3jp3s/MQMQgaqXJgMwEyCYChji
Va2P1kP/ijKHsoDc0Il6KWgDkyqw2l2KU0w46esCEl6izM+I7O6PAw2lAoGBAOOu
s2QQTT1Om8iN7hpSp8nLjJvDdWy6Q2zHKrd6KEHY1Xrvrgy/5xtldx66DNbDT647
9nShyh5A2UOBx6NV8PG7zWjoz28E8O1EWGiEIxgDIFrMn6aU9hOA9gYOprcqbpL0
fWGVYBy8dF2hinLUC9OGUw7F/+mLHqbuY12aOoHTAoGAUixJ3pW3F7Wk1TXnI9JX
+4i2txRk+A4Y+ssTq7OUzui0xgepRMb326VN5hCR3IoioryZBqSXp79e3F9Ws1oa
F+6Qo9gId/GwTB+s1DcSNoi0GNicp4PPsBvtbCVrA5mHiKUEpqRzNlwG6QXmrgcG
WaZhcdeGBsjpuAkAGrP5mwECgYBmsAZsnQWZHvkX7Rt0d88BLnLOVcuCLEf4qaNU
eR3rBNbTyYHgcjTToGGnVBYyToiDdrvjQo0cM/dJgSD/Q+WVwTQVmtrjoYDgIjEV
gnMpg092ZE+lHA4YIdPUS4tZlSOl1+sstehRTZXWHOOKgqSK1Exln1uag4phk6bx
MnwszQKBgQDVvg8QbHOVL82ZpqfoTmBY3+ZNrOHMlo8hH4X40veAhjKaSyAZw1qx
BEJVNgHT/UZkM10kAYtRNsmp0CFPyAY9rTy9ekEKfht6HSO10j8Nzv3v+zI0DEx9
/2+0vcPQZyKVHz//VJPQ5g084l22qMdLCDqVWkZbfgVJkjH45LIY5w==
-----END RSA PRIVATE KEY-----

更新:

所以我回到家查看了 /var/log/auth.log(谢谢!)。连接时我只得到:

sshd[2421]: Did not receive identification string from 999.999.999.999

当我在调试模式下运行 sshd 时,我得到的是:

sshd[2423]: debug1: sshd version OpenSSH_5.3p1 Debian-3ubuntu4                       
sshd[2423]: debug1: read PEM private key done: type RSA                              
sshd[2423]: debug1: Checking blacklist file /usr/share/ssh/blacklist.RSA-2048        
sshd[2423]: debug1: Checking blacklist file /etc/ssh/blacklist.RSA-2048              
sshd[2423]: debug1: private host key: #0 type 1 RSA                                  
sshd[2423]: debug1: read PEM private key done: type DSA                              
sshd[2423]: debug1: Checking blacklist file /usr/share/ssh/blacklist.DSA-1024        
sshd[2423]: debug1: Checking blacklist file /etc/ssh/blacklist.DSA-1024              
sshd[2423]: debug1: private host key: #1 type 2 DSA                                  

提到的黑名单文件不存在。

答案1

id_rsa 密钥文件必须包含一个标头块来标识类型。看来它已损坏。您可能应该尝试使用 keygen 命令重新创建密钥。

我的 cygwin 生成的密钥文件的标题如下:

-----开始 RSA 私钥-----
Proc-Type:4,已加密
DEK 信息: AES-128-CBC,48818Cxxxxxxxxxxxxxxxxxxxxxxxxxx

相关内容