Skip to content

Key exchange negotiation failed #1105

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

Closed
okarpov opened this issue Mar 27, 2023 · 8 comments · Fixed by #1177
Closed

Key exchange negotiation failed #1105

okarpov opened this issue Mar 27, 2023 · 8 comments · Fixed by #1177
Milestone

Comments

@okarpov
Copy link

okarpov commented Mar 27, 2023

Renci.SshNet.Common.SshConnectionException: Key exchange negotiation failed.
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout) in \SSH.NET-rsa-sha2-256\src\Renci.SshNet\Session.cs:line 977
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle) in \SSH.NET-rsa-sha2-256\src\Renci.SshNet\Session.cs:line 874
at Renci.SshNet.Session.ConnectAsync(CancellationToken cancellationToken) in \SSH.NET-rsa-sha2-256\src\Renci.SshNet\Session.cs:line 739
at Renci.SshNet.BaseClient.CreateAndConnectSessionAsync(CancellationToken cancellationToken) in \SSH.NET-rsa-sha2-256\src\Renci.SshNet\BaseClient.cs:line 545
at Renci.SshNet.BaseClient.ConnectAsync(CancellationToken cancellationToken) in \SSH.NET-rsa-sha2-256\src\Renci.SshNet\BaseClient.cs:line 284
at

@scott-xu
Copy link
Collaborator

Is the server OpenSSH 6.5 or 6.6? @okarpov

@okarpov
Copy link
Author

okarpov commented Aug 19, 2023

ssh -V
OpenSSH_8.2p1 Ubuntu-4ubuntu0.8, OpenSSL 1.1.1f 31 Mar 2020

@scott-xu
Copy link
Collaborator

scott-xu commented Aug 21, 2023

Then the case is different with mine. I got the same error message when connect to OpenSSH 6.6 and I believe it is caused by the wrong Bignum encoding in OpenSSH 6.5/6.6. OpenSSH fixed the issue in 6.7 (and 6.6.1). See https://www.openssh.com/txt/release-6.7
BTW, I think ssh -V is to display SSH client version but not server version.

@scott-xu
Copy link
Collaborator

Then the case is different with mine. I got the same error message when connect to OpenSSH 6.6 and I believe it is caused by the wrong Bignum encoding in OpenSSH 6.5/6.6. OpenSSH fixed the issue in 6.7 (and 6.6.1). See https://www.openssh.com/txt/release-6.7 BTW, I think ssh -V is to display SSH client version but not server version.

Hi @WojciechNagorski, could we consider removing curve25519-sha256 and curve25519-sha256@libssh.org key exchange algorithms when speaking to OpenSSH 6.5 and 6.6? See openssh/openssh-portable@9395b28

Alternatively, we could expose some event during negotiation so that the caller can attach a handler to the event and filter the key exchange algorithems.

Here's the line where we could add the filter logic: https://github.com/sshnet/SSH.NET/blob/develop/src/Renci.SshNet/Session.cs#L608

I can create PR if that's okay.

@scott-xu
Copy link
Collaborator

scott-xu commented Sep 28, 2023

FYI, this is the root fix in OpenSSH: openssh/openssh-portable@adbfdbb

@WojciechNagorski
Copy link
Collaborator

@scott-xu can you create a new issue for this. I didn't know about this problem.

@scott-xu
Copy link
Collaborator

#1191 is created.

@WojciechNagorski
Copy link
Collaborator

Version 2023.0.0 has been published https://www.nuget.org/packages/SSH.NET/2023.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants