Skip to content

Conversation

lrm29
Copy link
Contributor

@lrm29 lrm29 commented Nov 15, 2024

User sees this error when trying to clone a repository using SSH:

failed to start SSH session: Unable to exchange encryption keys (-1x23)

This particular server only accepts these host key algorithms (output from ssh executable):

debug2: host key algorithms: rsa-sha2-256,rsa-sha2-512

"Normally" you might see others but what causes the error is the absence of "ssh-rsa" from the accepted list of host key algorithms.

Calling libssh2_session_method_pref with a list of methodsunfortunately isn't just preferring those methods, it means it accepts ONLY those methods. This pull request fixes that by adding rsa-sha2-256 and rsa-sha2-512 to the list.

This could be optimised by only calling libssh2_knownhost_checkp once for LIBSSH2_KNOWNHOST_KEY_SSHRSA and appending all of rsa-sha2-256, rsa-sha2-512. and ssh-rsa if mismatch is returned.

@ethomson ethomson merged commit c86842f into libgit2:main Nov 26, 2024
19 checks passed
@ethomson
Copy link
Member

Thanks!

@lrm29 lrm29 deleted the lrm29-ssh-hostkey-check branch December 12, 2024 22:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants