Situation: MVS2017 App - Using 'Git Bash' on Windows 10 - Trying to connect to a BitBucket repository.
To be clear, when you install Git for Windows (https://git-scm.com/download/win), it comes with an utility called Git Bash.
So, I am in 'Git Bash', as follows:
Mike@DUBLIN MINGW64 ~/source/repos/DoubleIrish (master)
$ git remote add origin git@bitbucket.org:Guiness/DoubleIrish.git
$ git remote -v
origin git@bitbucket.org:Guiness/DoubleIrish.git (fetch)
origin git@bitbucket.org:Guiness/DoubleIrish.git (push)
Mike@DUBLIN MINGW64 ~/source/repos/DoubleIrish (master)
$ git push -u origin master
[...]
git@bitbucket.org: Permission denied (publickey).
fatal: Could not read from remote repository.
Is the private key set up?
$ ssh -V
OpenSSH_7.7p1, OpenSSL 1.0.2p 14 Aug 2018
$ ls -a ~/.ssh
./ ../ known_hosts
I can see that, at this point, my private key file (id_rsa
) is missing. So I add it:
(note: generating a pair of private-public keys is out of scope of my reply, but
I can say that in Linux, you can use ssh-keygen
for that.)
$ ls -a ~/.ssh
./ ../ id_rsa known_hosts
OK, let's proceed:
$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-KhQwFLAgWGYC/agent.18320; export SSH_AUTH_SOCK;
SSH_AGENT_PID=17996; export SSH_AGENT_PID;
echo Agent pid 17996;
$ ssh-add ~/.ssh/id_rsa
Could not open a connection to your authentication agent.
To solve this, I run:
$ ssh-agent bash
And then, again:
$ ssh-add ~/.ssh/id_rsa
Identity added: /c/Users/Mike.CORP/.ssh/id_rsa (/c/Users/Mike.CORP/.ssh/id_rsa)
It worked for me. Hope this helps