Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

ssh: handshake failed: knownhosts: key mismatch #738

Open
@TinyWisp

Description

@TinyWisp

I tried to write codes for cloning a repository via ssh protocol, it failed with the error:

ssh: handshake failed: knownhosts: key mismatch

my codes:

package main

import (
        "fmt"
        "os"

        git "gopkg.in/src-d/go-git.v4"
        ssh "gopkg.in/src-d/go-git.v4/plumbing/transport/ssh"
)

func main() {
        auth, err := ssh.NewPublicKeysFromFile("git", "/root/.ssh/id_rsa", "")
        fmt.Println(err)

        _, err2 := git.PlainClone("./dvue", false, &git.CloneOptions{
                URL:           "[email protected]:work/LocalService.git",
                ReferenceName: "refs/head/master",
                Auth:          auth,
                Progress:      os.Stdout,
        })

        fmt.Println(err2)
}

When I tried the following command, it was all right.

git clone [email protected]:work/LocalService.git

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions