[英]Cloning git repo causes error - Host key verification failed. fatal: The remote end hung up unexpectedly
我使用SSH將git repo克隆到我的Web服務器,但每次出現此錯誤
$git clone git@github.com:aleccunningham/marjoram.git
Cloning into marjoram...
Host key verification failed.
我已經嘗試了幾乎所有在谷歌搜索中出現的內容,而且我為什么這不起作用而傻眼了。 有任何想法嗎?
另外,我沒有使用詹金斯這樣的東西。
問題可能是你的〜/ .ssh / known_hosts文件中沒有Github。
將GitHub附加到授權主機列表:
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
解決了問題...您需要將ssh公鑰添加到您的github帳戶。
ssh-keygen
~/.ssh/id_rsa
) ~/.ssh/id_rsa.pub
)添加到github帳戶 git clone
。 有用!
初始狀態(公鑰未添加到git hub帳戶)
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:~$
現在,將公鑰~/.ssh/id_rsa.pub
到github帳戶(我使用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)
好吧,從sourceTree我無法解決這個問題,但我從bash創建了sshkey,至少它是從git-bash開始的。
https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html
我有同樣的問題,解決方案非常簡單,只需從cmd或其他Windows命令行工具更改為git bash。 Windows有時與git npm依賴項不兼容。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.