"Invalid identification string” error
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 5.8k
- Forks
- 734
- PR merge metrics
- No merged PRs in 30d
Description
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:
node:events:368
throw er; // Unhandled 'error' event
^
Error: Invalid identification string
at Protocol.parseHeader [as _parse] (D:\dh\code\try-nodejs\node_modules\?[4mssh2?[24m\lib\protocol\Protocol.js:1935:17)
at Protocol.parse (D:\dh\code\try-nodejs\node_modules\?[4mssh2?[24m\lib\protocol\Protocol.js:293:16)
at Socket.<anonymous> (D:\dh\code\try-nodejs\node_modules\?[4mssh2?[24m\lib\client.js:713:21)
?[90m at Socket.emit (node:events:390:28)?[39m
?[90m at addChunk (node:internal/streams/readable:315:12)?[39m
?[90m at readableAddChunk (node:internal/streams/readable:289:9)?[39m
?[90m at Socket.Readable.push (node:internal/streams/readable:228:10)?[39m
?[90m at TCP.onStreamRead (node:internal/stream_base_commons:199:23)?[39m
Emitted 'error' event on Client instance at:
at Socket.<anonymous> (D:\dh\code\try-nodejs\node_modules\?[4mssh2?[24m\lib\client.js:715:20)
?[90m at Socket.emit (node:events:390:28)?[39m
[... lines matching original stack trace ...]
?[90m at TCP.onStreamRead (node:internal/stream_base_commons:199:23)?[39m
After added some debug code to Protocol.js , I found the identification string from the switch might not match standard well:
172.28.230.19: initiate
172.28.230.19: Connection.connect
Connected
<dh.debug>data
<Buffer 53 53 48 2d 32 2e 30 2d 20 20 20 20 20 20 20 0d 0a>
<dh.debug>full
SSH-2.0-
<dh.debug>identRaw
SSH-2.0-
so I bypass the throwing exception by changing code as below and then the script works as expected
if (!m){
// throw new Error('Invalid identification string');
m =[];
m[1] = '2.0';
m[2] ='';
m[3] =''
}
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:
debug1: Local version string SSH-2.0-OpenSSH_for_Windows_7.7
debug1: Remote protocol version 2.0, remote software version
debug1: no match:
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in lib/protocol/Protocol.js at Protocol.parseHeader around line 1935, then trace the client socket handling in lib/client.js around line 713. Reproduce the captured SSH-2.0- identification response from the switch and compare it with the parser's expected format. Done means the compatibility behavior is defined and verified without breaking handling of standard identification strings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- networking
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100