I'm trying to connect to a Git repository (on Bitbucket) with SSH from Visual Studio 2017 (which, as far as I know, supports SSH for Git). I have everything set up, the repository cloned on my computer, and I can commit, but if I try to do something like fetching it fails with the following message (from Visual Studio's "Output" window):
Error encountered while fetching: Git failed with a fatal error.
fatal: Could not read from remote repository.
Trying it from the command prompt, I get these slightly more informative messages:
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
From Git Bash I have tried opening the SSH agent, adding my private key, and fetching, and it seems to work (or at least I don't get any messages, unlike when the agent is not started or the key not added):
eval `ssh-agent`
ssh-add ~/.ssh/xxxx
git fetch
But Visual Studio is still unable to connect. I have also tried to do the same from the Windows command prompt:
ssh-agent
set SSH_AUTH_SOCK=/tmp/ssh-SIAryCa61iz9/agent.11128
set SSH_AGENT_PID=9804
ssh-add xxxx
git fetch
But I still get the same error.
I already added the public key to Bitbucket, and ssh -T git@bitbucket.org
does output "logged in as xxxx". Also, I can connect correctly using SourceTree and adding the private key to Pageant (the key I use for ssh-add
has the required OpenSSH format, I created it from the .ppk one).