Skip to content

ssh2 node js sftp protocol Error Handshake failed

Hello i have a little problem, i developped a script sftp client with node js that connect to an sftp server and grab some files, i tested it with my local server its working, but when i tried to use it with production server i received this error :

Error: Handshake failed: no matching key exchange algorithm

i already generated the rsa key using ssh-keygen

here is the relevant part of the script :

var Client = require('ssh2').Client;
var fs = require('fs');
var path = require('path');

var args = process.argv.slice(2);

var connSettings = {
    host: args[0] || '',
    port: args[1] || 22,
    username: args[2] || 'karim',
    password: args[3] || 'karimos',
    algorithms: {
        hmac: ['hmac-sha2-256', 'hmac-sha2-512', 'hmac-sha1', 'hmac-sha1-96']



I also had the same problem and solved it by adding the following:

algorithms: {
        kex: [
        cipher: [
          "[email protected]",
          "[email protected]"
        serverHostKey: [
        hmac: [