Skip to content

ssh: handshake failed: knownhosts: key mismatch #18

@trotterdylan

Description

@trotterdylan

This error can happen when performing git remote operations (e.g. a push) on a remote configured with ssh. It seems like this is caused by multiple github.com entries in known_hosts, one of which uses an unsupported key or algorithm: https://github.blog/2021-09-01-improving-git-protocol-security-github/

In this case the Git library (or the underlying SSH library) naively picks the first key, which may not work. Instead of trying other supported keys, the Dial call fails. This has been noted in go-git issue 411 and Golang issue 29286.

A PR that I believe addresses this has been written for go-git, but it hasn't yet been accepted: go-git/go-git#548

I'd rather not fork go-git and instead try to patch the way that we configure SSH auth, but it's not immediately clear how easy this will be.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions