Open daihang opened 2 years ago
Ran into this same issue today when attempting a connection known to work under earlier versions of this module (pre 1.0).
~Based on my (non-expert) read of RFC4253 Section 4.2, it doesn't explicitly state that the softwareversion
in the ident can't be all whitespace... although at best it means it is unclear whether some of the whitespace is meant to be comments
or whether it's all meant to be softwareversion
.~ EDIT: I'm a dummy. It very much says it can't be all whitespace, in fact it says it must not even contain whitespace.
That being said, I'd expect this library to log the ident to the debug handler/callback before raising this kind of error, because currently in order to actually see the ident in question I've had to use a downgraded version of the library.
(After downgrading and turning on debug logging, I got:)
SSH DEBUG: DEBUG: Local ident: 'SSH-2.0-ssh2js0.4.8'
SSH DEBUG: DEBUG: Client: Trying [redacted] on port 22 ...
SSH DEBUG: DEBUG: Client: Connected
SSH DEBUG: DEBUG: Parser: IN_INIT
SSH DEBUG: DEBUG: Parser: IN_GREETING
SSH DEBUG: DEBUG: Parser: IN_HEADER
SSH DEBUG: DEBUG: Remote ident: 'SSH-2.0- '
SSH DEBUG: DEBUG: Outgoing: Writing KEXINIT
SSH DEBUG: DEBUG: Parser: IN_PACKETBEFORE (expecting 8)
SSH DEBUG: DEBUG: Parser: IN_PACKET
SSH DEBUG: DEBUG: Parser: pktLen:676,padLen:5,remainLen:672
SSH DEBUG: DEBUG: Parser: IN_PACKETDATA
SSH DEBUG: DEBUG: Parser: IN_PACKETDATAAFTER, packet: KEXINIT
SSH DEBUG: DEBUG: Comparing KEXINITs ...
~But to be honest it seems like an argument could be made that supporting remote ident strings with all-whitespace softwareversion
values is a "need" rather than a "nice-to-have" since it's not disallowed by the relevant RFC. Maybe?~
The OpenSSH CLI client appears to not bother trying to distinguish between the softwareversion
and optional comments
at all:
https://github.com/openssh/openssh-portable/blob/V_8_9_P1/ssh_api.c#L383
For this particular server, OpenSSH logs:
debug1: Local version string SSH-2.0-OpenSSH_8.9p1 Ubuntu-3ubuntu0.1
debug1: Remote protocol version 2.0, remote software version
debug1: compat_banner: no match:
debug2: fd 3 setting O_NONBLOCK
There is an old switch I can ssh by MobaXterm or ssh client in Windows. But when I use ssh2 lib to connect, below error occurs:
After added some debug code to Protocol.js , I found the identification string from the switch might not match standard well:
so I bypass the throwing exception by changing code as below and then the script works as expected
I guess the root cause shoud be the switch's bug, but is it possible to be compatible with this case like MobaXterm?
FYI: the identificatin output when run "ssh -vvv [user]@[IP]" from Windows CMD: