【问题标题】:Git pull doesn't work without running ssh-add -K previously on Azure如果之前在 Azure 上运行 ssh-add -K,Git pull 将无法工作
【发布时间】:2020-05-11 13:56:04
【问题描述】:

我的 ~/.ssh/config

Host MyAzureAlias
  HostName ssh.myhostname.azure.com
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa_azure_key

Host MyBitbucketAlias
  HostName bitbucket.org
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/id_rsa_bitbucket_key

然后我跑

ssh-add -K ~/.ssh/id_rsa_azure_key
ssh-add -K ~/.ssh/id_rsa_bitbucket_key

然后我打开了 webstorm 并打开了两个项目。我拉了bitbucket。成功。 我在 azure 上进行了拉动,但出现错误:remote: Public key authentication failed。致命:无法从远程存储库中读取。请确保您拥有正确的访问权限并且存储库存在。

然后我运行ssh -v MyAzureAlias

在调试中我得到了 debug1: identity file /Users/myname/.ssh/id_rsa_azure_key

最后我得到了 debug1: Authentication succeeded (publickey)。

这意味着我的 MyAzureAlias 的 ~/.ssh/config 工作正常。

然后我运行 ssh-add -l 它给了我两个密钥。

然后我运行 eval "$(ssh-agent -s)" 然后我再次运行 ssh-add -l 并没有给我任何密钥。 p>

然后我跑

  • eval "$(ssh-agent -s)"
  • ssh-add -K ~/.ssh/id_rsa_azure_key

然后git pull成功。

配置:

  • ma​​cOS Catalina 10.15.4.
  • git 版本 2.24.1 (Apple Git-126)
  • ssh -V OpenSSH_8.1p1,LibreSSL 2.7.3

如何解决这个问题?

提前谢谢你!

【问题讨论】:

    标签: git azure ssh ssh-agent ssh-config


    【解决方案1】:

    如果身份验证成功,但 Git 存储库访问失败(在 Azure 上),则需要仔细检查使用的 URL。

    应该是:

    git ls-remote MyAzureAlias:<me>/<myrepo>
    

    确保大小写(小写/大写)正确

    【讨论】:

      猜你喜欢
      • 2013-10-24
      • 2013-09-12
      • 2021-09-04
      • 2021-07-09
      • 1970-01-01
      • 2021-09-12
      • 2019-07-19
      • 2017-11-15
      • 1970-01-01
      相关资源
      最近更新 更多