Repository navigation
make HostKeyCallbackHelper read known hosts for already known key algorithms - #64
Open
gmatiukhin wants to merge 1 commit into
Open
gmatiukhin wants to merge 1 commit into
gmatiukhin wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Read
known_hostswhenStrictHostKeyCheckingenabled to discover server host keys that are known to the runner and set the corresponding algorithms on the helper.Context
My git server machine has 3 host keys: RSA, ECDSA and Ed25519. One of my runners knows all 3 and has them in
known_hosts, a different runner knows only Ed25519. When using this backend from that machine it was failing withssh: handshake failed: knownhosts: key mismatchwhile plainsshworked fine.go-git selects host key types from
known_hostsinconnect()only when thessh.ClientConfighas noHostKeyCallback. But the built-in auth methods (PublicKeys,PublicKeysCallback) always fill one in:SetHostKeyCallbackAndAlgorithmsfalls back to theknown_hostscallback when the helper has none. In that case x/crypto/ssh uses its default order, in which ECDSA is before Ed25519, which made the git server machine to send ECDSA key. Because the failing runner had an entry for the git server machine inknown_hostswith a different key, it was failing withkey mismatchand notkey unknown. OpenSSH prefers the key types it already knows, which is why plainsshworks.Change
In strict mode the helper keeps a nil
HostKeyCallback, so go-git still uses itsknown_hostscallback and verification is unchanged. OnlyHostKeyAlgorithmsis set, fromknown_hostsforhost:portof the repository (port 22 when the URL has none).StrictHostKeyChecking=nobehaves as before.