Skip to content

Issue for large number of ssh connections with DH key exchange on CentOS 8.2 #934

Closed
@vishalsevani

Description

@vishalsevani

In my application I open large number of ssh connections (about 200) in parallel and then execute some commands on remote nodes.

My application runs properly on Ubuntu 20.04 with node 12.18.3.

However on CentOS 8.2 with nodejs 12.18.3, the ssh connections get timed out and also the CPU usage is constantly about 100%, so I cannot do any other activity via UI.

If I reduce the number of parallel ssh connections to about 50, then the application works on CentOS 8.2, but still the CPU is 100% when the ssh connections are going on.

Also the ssh is using DH key exchange as large number of devices in my network do not support other key exchanges. For the devices that support other key exchange algorithms like curve25519-sha256@libssh.org, my application runs properly on CentOS 8.2 as well. So the problem is with DH algorithm with large number of ssh connections on CentOS 8.2.

I can see a related issue for MAC OS here but the linked node issue is fixed, so why still the problem on CentOS 8.2 with node 12.18.3. Also just to reiterate, I don't see problem on Ubuntu 20.04 with node 12.18.3

Iam posting a code snippet to reproduce the error,

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

function getSSHConn(ip) {

    var conn = new Client();
    conn.on('ready', function() {
        console.log('ready' + ip);
        conn.end();
    }).on('error', function(err) {
        console.log(err);
    }).connect({
        host: ip,
        username: 'admin',
        password: 'abc123'
    });
  }

const ips = [array of 200 ips]
for (var i = 0; i < ips.length; i ++) {
        getSSHConn(ips[i]);
}

I have done CPU profiling and majority of ticks are in crypto::DH::New

[C++]:
   ticks  total  nonlib   name
  18281   95.5%   97.8%  node::crypto::DiffieHellman::New(v8::FunctionCallbackInfo<v8::Value> const&)
     97    0.5%    0.5%  node::native_module::NativeModuleEnv::CompileFunction(v8::FunctionCallbackInfo<v8::Value> const&)
     89    0.5%    0.5%  node::crypto::DiffieHellman::GenerateKeys(v8::FunctionCallbackInfo<v8::Value> const&)
     33    0.2%    0.2%  void node::StreamBase::JSMethod<&node::StreamBase::WriteBuffer>(v8::FunctionCallbackInfo<v8::Value> const&)

Any comments/help/clarification I can get on the issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions