【问题标题】:msysgit git clone ignores ssh configmsysgit git clone 忽略 ssh 配置
【发布时间】:2015-03-12 01:48:08
【问题描述】:

我已经安装了 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

【问题讨论】:

    标签: windows git ssh msysgit openssh


    【解决方案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 存储库的域。

    【讨论】:

      【解决方案2】:

      原因是我自己的疏忽。 Bitbucket 使用 bitbucket.org 进行回购。 Afaik,在使用 bitbucket.com 之前。

      【讨论】:

      • 我同意。我已经在我的回答中补充了这一点。
      猜你喜欢
      • 1970-01-01
      • 2015-08-20
      • 1970-01-01
      • 2012-04-24
      • 1970-01-01
      • 1970-01-01
      • 2020-04-18
      • 2012-08-04
      • 1970-01-01
      相关资源
      最近更新 更多