msysgit git clone忽略ssh配置

时间:2015-03-11 16:35:47

标签: windows git ssh msysgit openssh

我已经安装了msysgit,git使用了正确的ssh.exe。所有命令都在msysgit shell中执行(程序文件x86 sh.exe)。 然后我将〜/ .ssh / config文件设置为此

LogLevel DEBUG1

Host bitbucket.com
  HostName bitbucket.com
  PreferredAuthentications publickey
  IdentityFile /d/ssh/bitbucket.ppk
  IdentitiesOnly yes

然后ssh bitbucket.com效果很好:

$ ssh bitbucket.com
debug1: Connecting to bitbucket.com [131.103.20.173] port 22.
debug1: Connection established.
debug1: identity file /d/ssh/bitbucket.ppk type -1
debug1: identity file /d/ssh/bitbucket.ppk-cert type -1

但是当我尝试git clone git@bitbucket.org:User/reponame.git ssh调试消息时,我发现ssh甚至没有尝试选择bitbucket ppk,而是尝试使用默认密钥:

$ git clone git@bitbucket.org:user/reponame.git
Cloning into 'reponame'...
debug1: Connecting to bitbucket.org [131.103.20.168] port 22.
debug1: Connection established.
debug1: identity file /c/Users/bob/.ssh/id_rsa type -1
debug1: identity file /c/Users/bob/.ssh/id_rsa-cert type -1
debug1: identity file /c/Users/bob/.ssh/id_dsa type -1
debug1: identity file /c/Users/bob/.ssh/id_dsa-cert type -1
debug1: identity file /c/Users/bob/.ssh/id_ecdsa type -1
debug1: identity file /c/Users/bob/.ssh/id_ecdsa-cert type -1
debug1: identity file /c/Users/bob/.ssh/id_ed25519 type -1
debug1: identity file /c/Users/bob/.ssh/id_ed25519-cert type -1

我没有想法。

$ where git
C:\Program Files (x86)\Git\bin\git.exe
C:\Program Files (x86)\Git\cmd\git.exe

2 个答案:

答案 0 :(得分:1)

git clone git@bitbucket.org:User/reponame.git会查找~/.ssh/id_rsaid_rsa.pub,而不是/d/ssh/bitbucket.ppk

应该起作用(因为ssh bitbucket.com起作用):

git clone bitbucket.com:User/reponame.git

这实际上会使用~/.ssh/config文件中定义的参数。

bitbucket.com是配置文件中的条目(它可以真正命名),但HostName必须确实是bitbucket.org,这是存储Git存储库的域

答案 1 :(得分:0)

原因是我自己的注意力不集中。 Bitbucket使用bitbucket.org进行回购。 Afaik,在使用bitbucket.com之前。