16

When I want to use git on with azure devops (vsts) I can't use git clone, pull, push etc. I get the error:

remote: remote: Your Git command did not succeed. remote: Details: remote: Public key authentication failed. remote: fatal: Could not read from remote repository.

But when I use the command below it works, so the problem is not the key. ssh-agent sh -c 'ssh-add ~/.ssh/key; git push repo'

When I do a git clone, push, pull etc I thought it goes through your .ssh dir to automatically check which key to use. Anybody any idea on how to fix this?

3

5 Answers 5

27

Fixed it by creating ~/.ssh/config and added:

Host xxx.visualstudio.com
  IdentityFile ~/.ssh/key

Make sure to do chmod 0400 ~/.ssh/config

Sign up to request clarification or add additional context in comments.

1 Comment

15

I added in the ~/.ssh/config:

Host ssh.dev.azure.com
  IdentityFile ~/.ssh/[you private key file]

Comments

6

I solved the problem by adding the identity to the SSH provider with

ssh-add [path to your private key]

so, for instance:

ssh-add /home/myuser/.ssh/id_rsa

1 Comment

The only thing that worked for me. Definitely need more up votes !
5

My case was more tricky. VisualStudio.com banned my old ssh key and didn't bother to somehow notify me. Experimentally I figured out that I just need to add a new key and use it instead.

ssh-keygen -f ~/.ssh/new_key

In ~/.ssh/config:

Host vs-ssh.visualstudio.com
  IdentityFile ~/.ssh/new_key

That worked. Then fun thing was that they don't let you remove the old banned key from SSH Keys page.

Update: With OpenSSH 8.9p1 that makes ssh-rsa keys by default, you may need to enable ssh-rsa in ssh_config or ~/.ssh/config.

    PubkeyAcceptedAlgorithms +ssh-rsa
    HostkeyAlgorithms +ssh-rsa

See https://stackoverflow.com/a/72102410/4653540

Comments

1

Along a similar line as Yuriy Pozniak's solution, I simply removed and re-added my public key, and that resolved my issue.

Modifying the ~/.ssh/config file to explicitly point the azure devops host to my private key did not work for me.

1 Comment

Thanks! Adding a new public key worked for me. This is really crazy. Last night I am able to connect from Debian machine and I wake up in the Morning and suddenly I can't push changes to the repository. If it's Micro$oft, it has to be crazy.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.