Git: Public key authentication failed
I added in the ~/.ssh/config:
Host ssh.dev.azure.com
IdentityFile ~/.ssh/[you private key file]
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
Fixed it by creating ~/.ssh/config and added:
Host xxx.visualstudio.com
IdentityFile ~/.ssh/key
Make sure to do chmod 0400 ~/.ssh/config