Cloning git repo causes error - Host key verification failed. fatal: The remote end hung up unexpectedly

前端 未结 4 1301
甜味超标
甜味超标 2020-12-12 17:07

I am using SSH to clone a git repo to my web server, but every time I get this error

$git clone git@github.com:aleccunningham/marjoram.git
Cloning into marjo         


        
相关标签:
4条回答
  • 2020-12-12 17:21

    The issue could be that Github isn't present in your ~/.ssh/known_hosts file.

    Append GitHub to the list of authorized hosts:

    ssh-keyscan -H github.com >> ~/.ssh/known_hosts

    0 讨论(0)
  • 2020-12-12 17:23

    Well, from sourceTree I couldn't resolve this issue but I created sshkey from bash and at least it works from git-bash.

    https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html

    0 讨论(0)
  • 2020-12-12 17:34

    I had the same issue, and the solution is very simple, just change to git bash from cmd or other windows command line tools. Windows sometimes does not work well with git npm dependencies.

    0 讨论(0)
  • 2020-12-12 17:40

    Resolved the issue... you need to add the ssh public key to your github account.

    1. Verify that the ssh keys have been setup correctly.
      1. Run ssh-keygen
      2. Enter the password (keep the default path - ~/.ssh/id_rsa)
    2. Add the public key (~/.ssh/id_rsa.pub) to github account
    3. Try git clone. It works!


    Initial status (public key not added to git hub account)

    foo@bn18-251:~$ rm -rf test
    foo@bn18-251:~$ ls
    foo@bn18-251:~$ git clone git@github.com:devendra-d-chavan/test.git
    Cloning into 'test'...
    Permission denied (publickey).
    fatal: The remote end hung up unexpectedly
    foo@bn18-251:~$
    


    Now, add the public key ~/.ssh/id_rsa.pub to the github account (I used cat ~/.ssh/id_rsa.pub)

    foo@bn18-251:~$ ssh-keygen 
    Generating public/private rsa key pair.
    Enter file in which to save the key (/home/foo/.ssh/id_rsa): 
    Created directory '/home/foo/.ssh'.
    Enter passphrase (empty for no passphrase): 
    Enter same passphrase again: 
    Your identification has been saved in /home/foo/.ssh/id_rsa.
    Your public key has been saved in /home/foo/.ssh/id_rsa.pub.
    The key fingerprint is:
    xxxxx
    The key's randomart image is:
    +--[ RSA 2048]----+
    xxxxx
    +-----------------+
    foo@bn18-251:~$ cat ./.ssh/id_rsa.pub 
    xxxxx
    foo@bn18-251:~$ git clone git@github.com:devendra-d-chavan/test.git
    Cloning into 'test'...
    The authenticity of host 'github.com (207.97.227.239)' can't be established.
    RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
    Are you sure you want to continue connecting (yes/no)? yes
    Warning: Permanently added 'github.com,207.97.227.239' (RSA) to the list of known hosts.
    Enter passphrase for key '/home/foo/.ssh/id_rsa': 
    warning: You appear to have cloned an empty repository.
    foo@bn18-251:~$ ls
    test
    foo@bn18-251:~/test$ git status
    # On branch master
    #
    # Initial commit
    #
    nothing to commit (create/copy files and use "git add" to track)
    
    0 讨论(0)
提交回复
热议问题