2014-10-30 28 views
1

我遇到类似于git - Server host key not cached中的问题,但有一个问题使最佳解决方案无法正常工作。git - 未缓存的服务器主机密钥 - Windows Twist

扭曲的是,我试图从Stash克隆一个存储库,一个来自Atlassian的应用程序,比如我们公司用来存储其git存储库的git-hub。在我将公钥输入到Stash之后,我使用Git Bash尝试使用系统为我提供的ssh地址克隆存储库。这会是什么结果:因为我没有使用腻子尝试连接

$ git clone ssh://[email protected]:7999/teamproject/gitrepo.git 
Cloning into 'gitrepo'... 
The server's host key is not cached in the registry. You 
have no guarantee that the server is the computer you 
think it is. 
The server's rsa2 key fingerprint is: 
ssh-rsa 2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:12 
Connection abandoned. 
fatal: Could not read from remote repository. 

Please make sure you have the correct access rights 
and the repository exists. 

,我试图连接到服务器的SSH的解决方案:

$ ssh ssh://[email protected]:7999/teamproject/gitrepo.git 
ssh: stash.mycompany.com:7999/teamproject/gitrepo.git: no address associated with name 

,如果我试图缩短下来地址使用SSH可以识别,我得到一个不同的指纹比Git是拒绝:

$ ssh ssh://[email protected] 
The authenticity of host 'stash.mycompany.com (10.XX.XXX.XX)' can't be established. 
RSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:34. 
Are you sure you want to continue connecting (yes/no)? no 
Host key verification failed. 

我选择不继续连接,因为如果我不连接,它只是把不利于混帐做一个进入其工作到我的known_hosts文件中。

任何人都知道如何解决这个问题?

+0

因此,从长远来看,没有“扭曲,使最好的解决方案没有工作”,它只是工作。 – 2015-04-03 10:14:28

回答

4

我有一个同事给我一个暗示,最终让我过去了我的问题。我上面发布的直接问题的答案是我没有按照预期的格式给ssh端口号。你不指定这样的端口号...

ssh stash.mycompany.com:7999 

......而像这样:

ssh -p 7999 stash.mycompany.com 

这句法造成ssh来问我是否想存储在主机已知主机名单,它给了我Stash告诉我它应该使用的指纹。 (当我说好的时候,ssh挂了我的Git Bash提示符,我不得不杀掉整个Git Bash会话并启动一个新的会话,但至少主机已经存储在known_hosts文件中:))

有一次我过去的这个问题,我不得不做的唯一的另一件事是在这个线程github: No supported authentication methods available,这是设置GIT_SSH变量在我的.bash_profile的混帐击

export GIT_SSH=/bin/ssh.exe 

应用解决方案,我做了后并重新启动Git Bash,git开始使用我的ssh密钥工作。

+0

一定要接受答案 - 即使它是你自己的!这非常有用 - 谢谢! – 2015-02-23 17:25:53