Git SSH 公钥身份验证在 Azure DevOps 上使用 git 失败 [英] Git SSH public key authentication failed with git on Azure DevOps

查看:38
本文介绍了Git SSH 公钥身份验证在 Azure DevOps 上使用 git 失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将 git 存储库从 PowerShell 推送到 Azure DevOps 存储库,但在尝试推送时我不断收到不同的身份验证错误.

I am trying to push a git repo from PowerShell into an Azure DevOps repo, and I keep getting different auth errors when trying to push it.

我希望有人能对我检查的内容有所了解,并进行适当的演练.

I am hoping somebody can shed some light on what I check, and do a proper walkthrough.

例如,

git remote add origin git@ssh.dev.azure.com:v3/MyAzure/MyProject/MyRepo
git push -u origin --all

我不断得到:

git@ssh.dev.azure.com 的密码:

git@ssh.dev.azure.com's password:

我已经输入了各种密码,但仍然失败.它在谈论哪个密码?

I've input all sorts of passwords, but it's still failing. Which password is it talking about?

或者,我也得到了:

权限被拒绝,请重试.

致命:无法从远程存储库读取.

fatal: Could not read from remote repository.

请确保您拥有正确的访问权限并且存储库存在.

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

验证:

$ ssh -T myemail@mycompany.com
ssh: connect to host mycompany.com  port 22: Connection refused

我做了以下事情:

  • 在 Azure DevOps 中创建了一个存储库
  • 使用 git-bash 创建了一个 SSH 密钥,按照 Microsoft 的文档,复制并粘贴到 Azure DevOps 安全性中,没有空格.
  • 转到我的个人资料/安全并添加一个 SSH 密钥(在 git-bash 中生成)

我是否错过了显而易见的事情?使用个人访问令牌更好吗?任何人都可以提供正确步骤的演练吗?

Am I missing the obvious? Is it better to use personal access token? Can anyone provide a walk through of the correct steps?

推荐答案

这对我有用

~/.ssh/中添加配置文件

并添加这些行

Host ssh.dev.azure.com
IdentityFile ~/.ssh/my_ssh_private_key
IdentitiesOnly yes

这个 link @wcoder 帮助

This link by @wcoder helped

这篇关于Git SSH 公钥身份验证在 Azure DevOps 上使用 git 失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆