Skip to content
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

libssh2_session_handshake LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE #1370

Open
PengShiJin opened this issue Apr 16, 2024 · 6 comments
Open

libssh2_session_handshake LIBSSH2_ERROR_KEY_EXCHANGE_FAILURE #1370

PengShiJin opened this issue Apr 16, 2024 · 6 comments

Comments

@PengShiJin
Copy link

I'm running libssh2 on an ARM development board and I'm having a problem with not being able to exchange keys. But I can't find a solution. When calling the "libssh2_session_handshake" function it keeps returning -8. Can anyone tell me how to solve this problem, thanks a lot!
image
image

@vszakats
Copy link
Member

Which libssh2 version and crypto-backend/version is this happening with?

@PengShiJin
Copy link
Author

Which libssh2 version and crypto-backend/version is this happening with?

This is the version of the target host.
image

Versions I compiled: libssh2-1.11.0 and openssl1.1.1d

After I created the rsa key pair using ssh-keygen. The default address where the key pair is saved is "/root/.ssh/" I don't know if this has any effect. Then I gave the key pair "777" permissions. But it still doesn't work.
image

Can anyone help me with why this is happening?

@victorstewart
Copy link

i'm getting the same failure #1369 (comment)

@PengShiJin
Copy link
Author

i'm getting the same failure #1369 (comment)

I've tried using versions 1.8.0 through 1.11.0, and they all fail without exception. However, when I use the lower versions I no longer get "key exchange failed" errors, but "free" and "malloc" errors. I don't understand why this is happening.

@YiShuiHanFeng
Copy link

i have the same problem in windows when libssh2_session_handshake excute.The version is 1.11.0. I dont understand Why.

@logmanoriginal
Copy link

Just putting this out here: I had a similar issue in version 1.11.0 on Windows, using the WINCNG backend.

The debug trace showed:

Key Ex: Agreed on KEX method: diffie-hellman-group-exchange-sha256
...
Failure Event: -5 - dh key pair generation failed
Failure Event: -8 - Unrecoverable error exchanging keys
Failure Event: -8 - Unable to exchange encryption keys

My workaround is avoiding deffie-hellman-group-exchange-sha256, either by selecting a different preferred method with libssh2_session_method_pref or by adding KexAlgorithms -diffie-hellman-group-exchange-sha256 to sshd_config.

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

No branches or pull requests

5 participants