我正在尝试将 git 存储库从 PowerShell 推送到 Azure DevOps 存储库,但在尝试推送时不断收到不同的身份验证错误。
我希望有人能够阐明我检查的内容,并进行适当的演练。
例如,
git remote add origin git@ssh.dev.azure.com:v3/MyAzure/MyProject/MyRepo
git push -u origin --all
我不断得到:
git@ssh.dev.azure.com's password:
我已经输入了各种密码,但仍然失败。它所说的密码是什么?
或者,我还得到了:
Permission denied, please try again.
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 中创建了存储库
- 根据 Microsoft 文档,使用 git-bash 创建 SSH key ,复制并粘贴到 Azure DevOps 安全性(不带空格)。
- 转到我的个人资料/安全并添加 SSH key (在 git-bash 中生成)
我错过了显而易见的事情吗?使用个人访问 token 更好吗?谁能提供正确步骤的演练?
最佳答案
将这些行添加到 ~/.ssh/config
任何通配符条目之前:
Host ssh.dev.azure.com
IdentityFile ~/.ssh/your_private_key
IdentitiesOnly yes
HostkeyAlgorithms +ssh-rsa
PubkeyAcceptedKeyTypes=ssh-rsa
这个link通过@wcoder 帮助。此外,DevOps only allows deprecated ssh-rsa
keys其中new versions of OpenSSH now block
最后,更荒谬的是,如果您有通配符条目(Host *
),您将需要 exclude DevOps禁止使用该条目中的任何键,因为 DevOps will blindly accept the first key that the client provides 🤦🏻♂️:
Host * !ssh.dev.azure.com
...
关于在 Azure DevOps 上使用 git 进行 Git SSH 公钥身份验证失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52985167/