克隆git回购会导致错误 - 主机密钥验证失败。致命的:远端意外挂断 [英] Cloning git repo causes error - Host key verification failed. fatal: The remote end hung up unexpectedly

查看:615
本文介绍了克隆git回购会导致错误 - 主机密钥验证失败。致命的:远端意外挂断的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SSH克隆一个git仓库到我的web服务器,但是每当我收到这个错误的时候

  $ git克隆git@github.com:aleccunningham / marjoram.git 
克隆到马郁兰...
主机密钥验证失败。

我已经尝试了Google搜索中显示的几乎所有内容,并且我为什么会这么做而目瞪口呆不行。任何想法?



另外,我没有使用类似Jenkins的任何东西。

解决了这个问题...您需要将ssh公钥添加到您的github帐户中。


  1. 验证ssh密钥是否有已正确设置。


    1. 运行 ssh-keygen

    2. 输入密码(保留默认路径 - 〜/ .ssh / id_rsa


    3. 添加公共密钥(〜/ .ssh / id_rsa.pub )到github账户

    4. 尝试 git clone 。它的工作原理!



    初始状态(未添加到git hub帐户的公钥)


      foo @ bn18-251:〜$ rm -rf测试
    foo @ bn18-251:〜$ ls
    foo @ bn18-251:〜$ git clone git@github.com:devendra-d-chavan / test.git
    克隆到'test'中...
    Permission denied(publickey )。
    致命:远程终端意外挂起
    foo @ bn18-251:〜$




    现在,将公钥〜/ .ssh / id_rsa.pub 添加到github帐户(我用 cat〜/ .ssh / id_rsa.pub


      foo @ bn18-251:〜$ ssh-keygen 
    生成公钥/私钥rsa密钥对。
    输入保存密钥的文件(/home/foo/.ssh/id_rsa):
    创建的目录'/home/foo/.ssh'。
    输入密码(没有密码时为空):
    再次输入相同的密码:
    您的身份已保存在/home/foo/.ssh/id_rsa中。
    您的公钥已保存在/home/foo/.ssh/id_rsa.pub。
    密钥指纹是:
    xxxxx
    密钥的randomart图像是:
    + - [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
    克隆到'test'中...
    主机'github.com'的真实性(207.97。 227.239)'无法建立。
    RSA密钥指纹是16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48。
    您确定要继续连接(是/否)吗?是
    警告:将github.com,207.97.227.239(RSA)永久添加到已知主机列表中。
    输入密钥'/home/foo/.ssh/id_rsa'的密码:
    警告:您似乎克隆了一个空的存储库。
    foo @ bn18-251:〜$ ls
    测试
    foo @ bn18-251:〜/ test $ git status
    #分支大师

    #初始提交

    无需提交(创建/复制文件并使用git add跟踪)



    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 marjoram...
    Host key verification failed.
    

    I have tried almost everything that has shown up in Google searches, and I am dumbfounded on why this will not work. Any ideas?

    Also, I am not using anything like Jenkins.

    解决方案

    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)
    

    这篇关于克隆git回购会导致错误 - 主机密钥验证失败。致命的:远端意外挂断的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆