我遇到过一些情况(例如 OSGi API,端口 2222),通过 PuTTY 的 SSH 连接在登录时无法进行身份验证,而通过 mRemoteNG 的完全相同的身份验证用户/密码却可以成功。
PuTTY 的失败症状是显示一个PuTTY Fatal Error
带有以下消息的消息框:
“服务器意外关闭网络连接”
在服务器中没有相应的日志条目/var/log/secure
。
均通过端口 22 成功进入同一服务器。两者都使用 SSH 2.0。
在 PuTTY 日志记录中启用后All session output
,仅记录以下内容:
=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2017.12.26 13:11:05 =~=~=~=~=~=~=~=~=~=~=~=
login as: root
Further authentication required
SSH server: Password authentication
Using keyboard-interactive authentication.
Password:
当我启用时SSH packets and raw data
,putty.log 包含了更多信息。为了简洁起见,我省略了原始数据:
=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2017.12.26 13:15:10 =~=~=~=~=~=~=~=~=~=~=~=
Event Log: Writing new session log (SSH raw data mode) to file: putty.log
Event Log: Connecting to 192.168.1.2 port 2222
Event Log: We claim version: SSH-2.0-PuTTY_Release_0.69
Incoming raw data at 2017-12-26 13:15:10
00000000 53 53 48 2d 32 2e 30 2d 53 53 48 44 2d 43 4f 52 SSH-2.0-SSHD-COR
00000010 45 2d 30 2e 39 2e 30 0d 0a E-0.9.0..
Event Log: Server version: SSH-2.0-SSHD-CORE-0.9.0
Event Log: Using SSH protocol version 2
Outgoing packet #0x0, type 20 / 0x14 (SSH2_MSG_KEXINIT)
...
Outgoing raw data at 2017-12-26 13:15:10
...
Incoming raw data at 2017-12-26 13:15:10
...
Incoming packet #0x0, type 20 / 0x14 (SSH2_MSG_KEXINIT)
...
Event Log: Using Diffie-Hellman with standard group "group14"
Event Log: Doing Diffie-Hellman key exchange with hash SHA-1
Outgoing packet #0x1, type 30 / 0x1e (SSH2_MSG_KEXDH_INIT)
...
Outgoing raw data at 2017-12-26 13:15:10
...
Incoming raw data at 2017-12-26 13:15:10
...
Incoming packet #0x1, type 31 / 0x1f (SSH2_MSG_KEXDH_REPLY)
...
Event Log: Host key fingerprint is:
Event Log: ssh-dss 1024 e6:85:76:7f:cb:6e:b6:21:b7:47:d0:86:a6:3f:3c:b6
Outgoing packet #0x2, type 21 / 0x15 (SSH2_MSG_NEWKEYS)
Outgoing raw data at 2017-12-26 13:15:10
...
Event Log: Initialised AES-256 SDCTR client->server encryption
Event Log: Initialised HMAC-SHA1 client->server MAC algorithm
Outgoing raw data at 2017-12-26 13:15:10
Incoming raw data at 2017-12-26 13:15:10
...
Incoming packet #0x2, type 21 / 0x15 (SSH2_MSG_NEWKEYS)
Event Log: Initialised AES-256 SDCTR server->client encryption
Event Log: Initialised HMAC-SHA1 server->client MAC algorithm
Outgoing packet #0x3, type 5 / 0x05 (SSH2_MSG_SERVICE_REQUEST)
...
Outgoing raw data at 2017-12-26 13:15:10
...
Incoming raw data at 2017-12-26 13:15:10
...
Incoming packet #0x3, type 6 / 0x06 (SSH2_MSG_SERVICE_ACCEPT)
...
Outgoing packet #0x4, type 50 / 0x32 (SSH2_MSG_USERAUTH_REQUEST)
...
Outgoing raw data at 2017-12-26 13:15:12
...
Incoming raw data at 2017-12-26 13:15:12
...
Incoming packet #0x4, type 51 / 0x33 (SSH2_MSG_USERAUTH_FAILURE)
...
Event Log: Further authentication required
Outgoing packet #0x5, type 50 / 0x32 (SSH2_MSG_USERAUTH_REQUEST)
...
Outgoing raw data at 2017-12-26 13:15:12
...
Event Log: Attempting keyboard-interactive authentication
Incoming raw data at 2017-12-26 13:15:13
...
Incoming packet #0x5, type 60 / 0x3c (SSH2_MSG_USERAUTH_INFO_REQUEST)
...
Outgoing packet #0x6, type 61 / 0x3d (SSH2_MSG_USERAUTH_INFO_RESPONSE)
...
Outgoing packet #0x7, type 2 / 0x02 (SSH2_MSG_IGNORE)
...
Outgoing raw data at 2017-12-26 13:15:15
...
Incoming raw data at 2017-12-26 13:15:15
...
Incoming packet #0x6, type 52 / 0x34 (SSH2_MSG_USERAUTH_SUCCESS)
Event Log: Access granted
Event Log: Opening session as main channel
Outgoing packet #0x8, type 90 / 0x5a (SSH2_MSG_CHANNEL_OPEN)
...
Outgoing raw data at 2017-12-26 13:15:15
...
Incoming raw data at 2017-12-26 13:15:15
...
Incoming packet #0x7, type 91 / 0x5b (SSH2_MSG_CHANNEL_OPEN_CONFIRMATION)
...
Event Log: Opened main channel
Outgoing packet #0x9, type 98 / 0x62 (SSH2_MSG_CHANNEL_REQUEST)
...
Outgoing raw data at 2017-12-26 13:15:15
...
Outgoing packet #0xa, type 98 / 0x62 (SSH2_MSG_CHANNEL_REQUEST)
...
Outgoing raw data at 2017-12-26 13:15:15
...
Event Log: Server unexpectedly closed network connection
知道什么可以两个看似兼容的 SSH 客户端之间存在差异的原因是什么?
更新:
在发现 mRemoteNG 使用了 PuTTY 的修改版本 mPuTTYNG(外观和感觉与 PuTTY 完全一样,但与 PuTTY 不同的是,它可以成功连接到远程主机)后,我也为其启用了日志并比较了差异:
看来,两者使用了一个显著不同的密码集... 可以那是原因吗?
另一方面,两者都使用具有完全相同的组和哈希值的 Diffie-Hellman:
Event Log: Using Diffie-Hellman with standard group "group14"
Event Log: Doing Diffie-Hellman key exchange with hash SHA-1
答案1
如能得到有关如何解决此问题的任何提示,我将非常感激。
我要做的第一件事就是查看应用程序和服务器的日志。然后我会根据从中了解到的信息继续进行。