question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handshake failed: no matching host key format

See original GitHub issue

Hi There,

I am hoping you can help me trace down this error that’s coming from this lib. we have a service using this library to connect to sftp and when we moved the docker to another host one of the sftp accounts started failing and generating these errors. I can sftp directly from that node to the valid account, however we fail when using this library.

I am a bit unsure what would be causing this, so any direction you can point me in is much appreciated.

Error: Handshake failed: no matching host key format
    at check_KEXINIT (/var/www/node_modules/ssh2-streams/lib/ssh.js:2268:15)
    at check (/var/www/node_modules/ssh2-streams/lib/ssh.js:2179:9)
    at onKEXINIT (/var/www/node_modules/ssh2-streams/lib/ssh.js:2176:5)
    at SSH2Stream.<anonymous> (/var/www/node_modules/ssh2-streams/lib/ssh.js:204:39)
    at emitOne (events.js:77:13)
    at SSH2Stream.emit (events.js:169:7)
    at parse_KEXINIT (/var/www/node_modules/ssh2-streams/lib/ssh.js:4028:8)
    at parsePacket (/var/www/node_modules/ssh2-streams/lib/ssh.js:3927:12)
    at SSH2Stream._transform (/var/www/node_modules/ssh2-streams/lib/ssh.js:652:13)
    at SSH2Stream.Transform._read (_stream_transform.js:167:10)
    at SSH2Stream._read (/var/www/node_modules/ssh2-streams/lib/ssh.js:236:15)
    at SSH2Stream.Transform._write (_stream_transform.js:155:12)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

20reactions
jasoncheowcommented, Mar 16, 2018

@Pushpinder2751 The following example works for me:

var ssh2 = require('ssh2')
var Client = require('ssh2').Client
var conn = new Client()
conn.on('ready', () => {
  console.log('Client :: ready')
}).connect({
  host: 'xxx',
  port: '22',
  username: 'xxx',
  password: 'xxx',
  algorithms: {
    serverHostKey: ['ssh-rsa', 'ssh-dss']
  }
})
20reactions
mscdexcommented, Oct 17, 2016

As I previously mentioned, you can already change the list of algorithms used during the handshake by setting the algorithms property of the connection config appropriately, so there is no need to modify the module’s source code. For example:

ssh.connect({
  // ...
  algorithms: {
    serverHostKey: [ 'ssh-rsa', 'ssh-dss' ],
  }
});
Read more comments on GitHub >

github_iconTop Results From Across the Web

No matching host key when connecting to sftp.webtrends.com
I am trying to use Firebase Cloud Functions to send a file to webtrends ftp server, but I have encountered a problem I...
Read more >
SFTP: Upload a File - How to resolve error: Handshake failed
"Error uploading file to SFTP server ###########: Handshake failed: no matching host key format". I couldn't find any documentation on this ...
Read more >
Handshake failed: No matching hostkey format - Ask Ubuntu
The error reads: Handshake failed: No matching hostkey format. Our solution is to change the SFTP hostkey encryption algorithm to one of the ......
Read more >
No matching host key found - Home | Hosted~FTP~ Help
No matching host key found? Read this brief article on how to use the command line or terminal to solve the no matching...
Read more >
Why is this SSH handshake failing? - encryption - Server Fault
... Unable to negotiate with 172.17.0.1 port 56408: no matching host key type found. ... Why can't they perform the handshake?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found