`ssh -T` to VSTS(Azure Devops) authenticates successfully, but `git clone` fails

前端 未结 3 1550
南笙
南笙 2021-01-05 06:39

I recently created a second key to access Visual Studio Team Services,

ssh-keygen -t rsa -b 4096 -C \"your_email@example.com\"

so I now ha

相关标签:
3条回答
  • 2021-01-05 07:22

    You need to force the client to use specific private key, otherwise it uses the default one.

    To check which private key file used for a host, you can run

    ssh -v [host(e.g. test@test.visualstudio.com)]
    

    One way is that you can configure it in the config file. (My steps for windows)

    1. Run touch .ssh/config if there isn’t config file in .ssh folder
    2. Open config file

    code:

    Host xx.visualstudio.com
      IdentityFile /c/Users/xx/.ssh/id_vsts
    
    1. Open new command line and run Git clone command

    Another way is that, you can run ssh -i /path/to/id_rsa user@server.nixcraft.com command.

    More information, you can refer to this article: Force SSH Client To Use Given Private Key (identity file)

    0 讨论(0)
  • 2021-01-05 07:29

    Apparently git uses only the first key provided, if that fails, git clone fails. My ssh config had a wildcard option with a key matching before the git key and therefore it did not work. After moving the git configuration to the top of .sss/config all is fine.

    0 讨论(0)
  • 2021-01-05 07:30

    In my case, adding IdentitiesOnly yes to the ~/.ssh/config file for the VSO host did the trick.

    0 讨论(0)
提交回复
热议问题