git - 如果之前在 Azure 上运行 ssh-add -K,Git pull 将无法工作
问题描述
我的 ~/.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 上进行了拉动,但出现错误:远程:公钥身份验证失败。致命:无法从远程存储库中读取。请确保您具有正确的访问权限并且存储库存在。
然后我运行ssh -v MyAzureAlias
在调试中我得到了debug1: identity file /Users/myname/.ssh/id_rsa_azure_key
最后我得到了debug1: Authentication succeeded (publickey)。
这意味着我的 ~/.ssh/config for MyAzureAlias工作正常。
然后我运行ssh-add -l它给了我两把钥匙。
然后我运行eval "$(ssh-agent -s)"然后我再次运行ssh-add -l它没有给我任何密钥。
然后我跑
- eval "$(ssh-agent -s)"
- ssh-add -K ~/.ssh/id_rsa_azure_key
然后git pull成功。
配置:
- macOS 卡塔利娜 10.15.4。
- git 版本 2.24.1 (Apple Git-126)
- ssh -V OpenSSH_8.1p1,LibreSSL 2.7.3
如何解决这个问题?
先感谢您!
解决方案
如果身份验证成功,但 Git 存储库访问失败(在 Azure 上),则需要仔细检查使用的 URL。
它应该是:
git ls-remote MyAzureAlias:<me>/<myrepo>
确保大小写(小写/大写)正确
推荐阅读
- r - 用于 R Shiny 发布的 RHEL Bash 脚本
- ios - iOS 自定义框架未在 Storyboard 上显示模块选项
- android - Android 从arraylist中的字符串中提取
- javascript - 如何使用 JavaScript Webdriver 访问 Selenium 的日志以查看网络请求
- sql - 将一列的值复制到不同行的另一列
- javascript - 在Javascript中的特定时间绘制正方形然后移动
- stream - 在 Beam 中流式传输
- kubernetes - Kubernetes 无法运行容器
- sql - SQL ORA-02063 - 如何解决这个问题?
- c# - 如何将sharepoint2010列表绑定到aspnet中继器控件