Git不使用SSH密钥对Azure DevOps进行身份验证

时间:2020-11-11 22:39:39

标签: bash git azure github ssh

我最近切换到运行工具箱的Fedora 33 Silverblue的新安装。这也发生在工具箱之外。我使用以下命令生成了SSH密钥

ssh-keygen -t rsa -b 4096 -C filbot@fenix

然后我将其上传到我的帐户下的Azure DevOps。但是,我无法使用以下~/.ssh/config从Azure DevOps克隆任何内容:

⬢[filbot@toolbox ~]$ cat ~/.ssh/config 
# SSH Configuration File
Host ssh.dev.azure.com
  HostName ssh.dev.azure.com
  User git
  IdentityFile /var/home/filbot/.ssh/id_rsa
  IdentitiesOnly yes
Host vs-ssh.visualstudio.com
  HostName vs-ssh.visualstudio.com
  User git
  IdentityFile /var/home/filbot/.ssh/id_rsa
  IdentitiesOnly yes

然后我运行这些git clone命令,结果如下:

⬢[filbot@toolbox ~]$ git clone git@ssh.dev.azure.com:v3/$ORG/$PROJ/Developer.dudleyp.cs_pipeline_tasks
Cloning into 'Developer.dudleyp.cs_pipeline_tasks'...
git@ssh.dev.azure.com's password: 

⬢[filbot@toolbox ~]$ GIT_SSH_COMMAND=ssh git clone git@ssh.dev.azure.com:v3/$ORG/$PROJ/Developer.dudleyp.cs_pipeline_tasks
Cloning into 'Developer.dudleyp.cs_pipeline_tasks'...
git@ssh.dev.azure.com's password: 

⬢[filbot@toolbox ~]$ ssh -T git@ssh.dev.azure.com
Warning: Permanently added the RSA host key for IP address '20.37.158.9' to the list of known hosts.
git@ssh.dev.azure.com's password: 

⬢[filbot@toolbox ~]$ ssh -i ~/.ssh/id_rsa -T git@ssh.dev.azure.com
git@ssh.dev.azure.com's password: 

似乎Git不尊重或什至不使用我的主目录中的ssh配置,就像之前或在其他较旧版本的Fedora或Pop!_OS中一样。我不明白为什么现在要这样做,以及如何获取信息以解决这个问题。

3 个答案:

答案 0 :(得分:1)

我遇到了完全相同的问题,并在这里找到了解决方案:

Fedora 33 git pull or clone no longer working and/or ssh key no longer recognized

基本上,在您的~/.ssh/config文件的每个Host部分下,添加PubkeyAcceptedKeyTypes ssh-rsa

Host ssh.dev.azure.com
  HostName ssh.dev.azure.com
  User git
  IdentityFile /var/home/filbot/.ssh/id_rsa
  IdentitiesOnly yes
  PubkeyAcceptedKeyTypes ssh-rsa

答案 1 :(得分:0)

使用-v在调试模式下运行ssh。它将输出在后台运行的整个过程。在输出中,将提到其使用的身份验证方法以及原因。

答案 2 :(得分:0)

似乎是Fedora 33的事情。我使用了Fedora 32工具箱,并且Git可以按预期工作。

➜  ~ toolbox create --release f32
Image required to create toolbox container.
Download registry.fedoraproject.org/f32/fedora-toolbox:32 (500MB)? [y/N]: y
Created container: fedora-toolbox-32
Enter with: toolbox enter --release 32
➜  ~ toolbox enter --release 32
⬢[filbot@toolbox ~]$ git clone -v git@ssh.dev.azure.com:v3/$ORG/$PROJ/Developer.dudleyp.cs_pipeline_tasks
Cloning into 'Developer.dudleyp.cs_pipeline_tasks'...
remote: Azure Repos
remote: Found 45 objects to send. (88 ms)
Receiving objects: 100% (45/45), 77.83 KiB | 25.94 MiB/s, done.
Resolving deltas: 100% (14/14), done.