我使用SSH将git repo克隆到我的Web服务器,但每次出现此错误
$git clone git@github.com:aleccunningham/marjoram.git
Cloning into marjoram...
Host key verification failed.
我已经尝试了几乎所有在Google搜索中出现的内容,而且我对为什么这不起作用感到茫然。有什么想法吗?
另外,我没有使用像Jenkins这样的东西。
答案 0 :(得分:135)
问题可能是Github没有出现在你的〜/ .ssh / known_hosts文件中。
将GitHub附加到授权主机列表中:
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
答案 1 :(得分:13)
解决了问题...您需要将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)
答案 2 :(得分:0)
好吧,从sourceTree上我无法解决此问题,但是我是从bash创建了sshkey,至少它在git-bash中有效。
https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html
答案 3 :(得分:-1)
我有同样的问题,解决方案很简单,只需从cmd或其他Windows命令行工具更改为git bash。 Windows有时与git npm依赖项不兼容。