sanketbajoria / ssh2-promise

ssh with promise/async await and typescript support
https://www.npmjs.com/package/ssh2-promise
MIT License
148 stars 24 forks source link

Unknown message digest on node v10.12.0 #10

Closed RichAyotte closed 5 years ago

RichAyotte commented 5 years ago

The following works fine on node v8.12.0 but fails with an Unknown message digest on v10.12.0

{
  host: 'sftp.my-site.com'
  , username: 'username'
  , password: 'password'
  , compress: true
  , algorithms: {
    kex: ['diffie-hellman-group1-sha1']
    , cipher: ['aes128-cbc']
    , serverHostKey: ['ssh-dss']
}

sftp.fastGet(file, `${targetPath}${file}`)

DEBUG

DEBUG: Parser: pktLen:1020,padLen:4,remainLen:1016
DEBUG: Parser: IN_PACKETDATA
DEBUG: Parser: IN_PACKETDATAAFTER, packet: KEXDH_REPLY
DEBUG: Checking host key format
DEBUG: Checking signature format
DEBUG: Verifying host fingerprint
DEBUG: Host accepted by default (no verification)
internal/crypto/sig.js:98
  this._handle.init(algorithm);
               ^

Error: Unknown message digest
    at new Verify (internal/crypto/sig.js:98:16)
    at Object.createVerify (crypto.js:141:10)
    at onKEXDH_REPLY (/home/rich/Projects/omn/backend/node_modules/ssh2-streams/lib/ssh.js:2876:25)
    at SSH2Stream.<anonymous> (/home/rich/Projects/omn/backend/node_modules/ssh2-streams/lib/ssh.js:215:45)
    at SSH2Stream.emit (events.js:182:13)
    at parse_KEXDH_REPLY (/home/rich/Projects/omn/backend/node_modules/ssh2-streams/lib/ssh.js:4220:8)
    at parse_KEX (/home/rich/Projects/omn/backend/node_modules/ssh2-streams/lib/ssh.js:4182:14)
    at parsePacket (/home/rich/Projects/omn/backend/node_modules/ssh2-streams/lib/ssh.js:4017:12)
    at SSH2Stream._transform (/home/rich/Projects/omn/backend/node_modules/ssh2-streams/lib/ssh.js:669:13)
    at SSH2Stream.Transform._read (_stream_transform.js:190:10)
    at SSH2Stream._read (/home/rich/Projects/omn/backend/node_modules/ssh2-streams/lib/ssh.js:251:15)
    at SSH2Stream.Transform._write (_stream_transform.js:178:12)
    at doWrite (_stream_writable.js:410:12)
    at writeOrBuffer (_stream_writable.js:394:5)
    at SSH2Stream.Writable.write (_stream_writable.js:294:11)
    at Socket.ondata (_stream_readable.js:666:20)
    at Socket.emit (events.js:182:13)
    at addChunk (_stream_readable.js:283:12)
    at readableAddChunk (_stream_readable.js:264:11)
    at Socket.Readable.push (_stream_readable.js:219:10)
    at TCP.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
RichAyotte commented 5 years ago

This looks more like a https://github.com/mscdex/ssh2-streams issue. I'll post the error there.

RichAyotte commented 5 years ago

The ssh2 and ssh2-streams dependencies are outdated in this package and are causing this issue.

The problem is fixed in the latest version of ssh2-streams 0.2.1 and ssh2 at 0.6.1.

sanketbajoria commented 5 years ago

Thanks a lot @RichAyotte for pointing it out. Let me fork a branch to test it out. if you could test it at your end, then i could publish it to npm.

RichAyotte commented 5 years ago

@sanketbajoria thanks for creating the issue#10 branch. The octothorp "#" in the branch name is giving me/yarn a hard time though. Something like the following usually works but I'm not sure how to escape the the "#" in the branch name.

yarn add https://github.com/sanketbajoria/ssh2-promise.git#issue#10 I also tried a bunch of combinations like yarn add https://github.com/sanketbajoria/ssh2-promise.git#issue%2310

Any ideas?

sanketbajoria commented 5 years ago

@RichAyotte , my bad. seems like yarn don't support it https://github.com/yarnpkg/yarn/pull/4881

I will rename the branch and push it again

sanketbajoria commented 5 years ago

I have renamed the branch from issue#10 to issue10

RichAyotte commented 5 years ago

I've confirmed that the issue10 branch fixes the problem. Thank you.

sanketbajoria commented 5 years ago

@RichAyotte Thanks a lot for confirming it. Merged it and pushed to npm repository