【问题标题】:Git not using SSH Key to authenticate to Azure DevOpsGit 不使用 SSH 密钥对 Azure DevOps 进行身份验证
【发布时间】:2020-11-13 07:06:15
【问题描述】:

我最近切换到运行工具箱的全新 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 似乎没有像以前或在其他较旧的 Fedora 或 Pop!_OS 安装中那样尊重甚至使用我的主目录中的 ssh 配置。我不明白它为什么现在这样做,以及如何获取信息以进一步解决这个问题。

【问题讨论】:

    标签: bash git azure github ssh


    【解决方案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
    

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 它处于调试模式,它显示了很多。你介意分享输出吗?
      • 当我使用git clone -v $url时,它仍然只显示登录。
      • 尝试 ssh -vv,这将输出可用的身份验证。
      • 还是什么都没有。我无法粘贴输出,因为它太长并且会丢失格式。它仍然只是提示输入凭据。 @Matt S. answer 成功了。
      【解决方案3】:

      这似乎是 Fedora 33 的东西。我使用了 Fedora 32 Toolbox,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.
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2015-10-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多