8000 host key mismatch after upgrading module from v5.12.0 to v5.13.0 · Issue #1341 · go-git/go-git · GitHub
[go: up one dir, main page]

Skip to content
host key mismatch after upgrading module from v5.12.0 to v5.13.0 #1341
@jgoodall

Description

@jgoodall

SSH git clone fails after update to v5.13.0. Specifically, the issue comes from ssh.FixedHostKey(hostKey) where we try to set the host key callback. The following works fine with v5.12.0, but fails with v5.13.0; the error is ssh: handshake failed: ssh: host key mismatch. So I dont think it is actually a host key mismatch, but something that changed in this module (or a dependency).

	hostKey, _, _, _, err := ssh.ParseAuthorizedKey([]byte(serverHostKey))
	if err != nil {
		return "", fmt.Errorf("unable to parse host key: %w", err)
	}
	pk, err := ssh2.NewPublicKeys(gitUser, []byte(repoPrivateKey), "")
	if err != nil {
		return "", fmt.Errorf("unable to create git public key: %w", err)
	}
	pk.HostKeyCallback = ssh.FixedHostKey(hostKey)
	deployBranch := gitplum.NewBranchReferenceName(gitBranch)
	r, err := git.PlainClone(destDirPath, false, &git.CloneOptions{
		URL:           repoURL,
		Auth:          pk,
	})
	if err != nil {
		return "", fmt.Errorf("unable to clone git repo [%s] (branch [%s]): %w", repoURL, deployBranch, err)
	}

I can use insecure and it works, but obviously I would like to verify the host key:

	pk.HostKeyCallback = ssh.InsecureIgnoreHostKey()

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0