Reputation: 1557
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?
Upvotes: 16
Views: 24030
Reputation: 695
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
Upvotes: 5
Reputation: 1859
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
Upvotes: 5
Reputation: 11
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.
Upvotes: 1
Reputation: 633
I added in the ~/.ssh/config:
Host ssh.dev.azure.com
IdentityFile ~/.ssh/[you private key file]
Upvotes: 15
Reputation: 1557
Fixed it by creating ~/.ssh/config and added:
Host xxx.visualstudio.com
IdentityFile ~/.ssh/key
Make sure to do chmod 0400 ~/.ssh/config
Upvotes: 27