Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Public key authentication failed

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?

like image 587
bramvdk Avatar asked Oct 08 '18 06:10

bramvdk


People also ask

How do I fix git authentication failed?

It happens if you change your login or password of git service account (Git). You need to change it in Windows Credentials Manager too. type "Credential Manager" in Windows Search menu open it. Windows Credentials Manager->Windows Credential and under Generic Credentials edit your git password.


1 Answers

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.

like image 103
Yuri Pozniak Avatar answered Sep 20 '22 13:09

Yuri Pozniak