-
Notifications
You must be signed in to change notification settings - Fork 671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Timed out while waiting for handshake stuck on Outgoing: Writing KEXINIT #927
Comments
I'm not sure I understand the situation. Are you changing IPs (on the client?) while connecting to an ssh server or ? |
no i'm just create the instance then attach the static ip, after 120 secs (this time is for ensuring that server is started) i start to connect to them one by one |
I do have the some problem, just update to v1.0.0 from v0.8.9 const { Client } = require('ssh2');
const conn = new Client();
conn.on('ready', () => {
console.log('Client :: ready');
}).connect({
host: '10.10.xxx.xx',
port: 22,
username: 'xxx',
password: 'xxxx',
}); the error is: events.js:291
throw er; // Unhandled 'error' event
^
Error: Timed out while waiting for handshake
at Timeout._onTimeout (C:\Users\sz_syit249\Desktop\node\node_modules\ssh2\lib\client.js:993:23)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7)
Emitted 'error' event on Client instance at:
at Timeout._onTimeout (C:\Users\sz_syit249\Desktop\node\node_modules\ssh2\lib\client.js:995:16)
at listOnTimeout (internal/timers.js:554:17)
at processTimers (internal/timers.js:497:7) {
level: 'client-timeout'
} |
@GeniusLuo what does the debug output show? |
@GeniusLuo can you try the master branch and see if that improves the situation? |
This is still an issue. I've raised it again here: https://github.com/theophilusx/ssh2-sftp-client/issues/351 But it looks like I should have been raising it here. This seems to be the prime calculation, its locking the server for up to 20 seconds while it calculates. Can this not pre-calculate or something, either as part of the install or initialisation process? I haven't gone into the SSH code yet to see if I can see where its going slow etc. but happy to be a tester. |
@Humphaz That is unrelated to the original issue here. The slowdown with diffie-hellman in general is in OpenSSL since many OpenSSL versions ago when they started performing additional checks on user-supplied primes for security reasons. There is no "pre-calcuation" that can be done for this (in fact, that'd be more or less like the fixed group diffie-hellman methods). Your best bet to avoid slowdowns is to use curve25519 where available (which this module currently prioritizes by default) as that doesn't trigger the same kind of checks within OpenSSL. |
Thanks mscdex, this isn't my comfort zone. 😃 My log looks like this for the handshake:
So I guess it is choosing:
So which one is it in the remote set?
Is this actually already choosing the one you recommended? |
Oh. I see, it is the ecdh-sha2-nistp256 and it isn't supported by the remote server. 😢 |
Ok, so I've used SFTP from the linux command line, it connects immediately and its using all of the same algortithms? How come this is instantaneous and yet, it takes 20 seconds to do it through code, obviously I know JS is a lot slower than C++, but it seems a bit excessive? Sorry if I'm making a total noob error here, but surely there is something that can be done? |
@Humphaz Two possibilities:
If you really want to know the answer you'd have to dig into the OpenSSH code and compare it with node's crypto code. |
I'm beginning to wonder if it's because it's offered options. I'm going to try and only offer the one used and see if that helps.
Thank you for taking the time out to look at this.
I will let you know how I get on later today.
Does that mean if I was just wanting hack to get around the issue for solving later, I could just miss out the check?
|
@Humphaz The |
I've run into this problem too. Having read the bug report in the node, the fix is essentially use Having looked into some of the KEX code in this library it looks like moving to For now, the solution is to make sure the upstream servers support EC based key exchanges, but this isn't always practical as we aren't the administrators of these servers. @mscdex are there any plans to move to an async based KEX? Would contributions to this end be welcome? |
Hi
i've wroten a node js script that connects to AWS cli then create instances and after some timeout (120 seconds) attach the static ips then connect to them and on ready event exucute some commands.
this proccess goes well but some times it get stuck on 1 istance
and after it detach ip and attach another one and after some timeout tries to connect but this error happen untill infinity.
i can connect to the same server with normal SSH but with ssh2 its not possible.
here is the debug logs:
and again
The text was updated successfully, but these errors were encountered: