Assuming you've installed git with default settings on Windows 10, and you have your ssh keys in ~/.ssh
(where ~
expands to something like C:/Users/user
) as something like id_rsa
and id_rsa.pub
, you'll be unable to use the git bash to clone repos with git clone [email protected]:user/project.git
. The git bash will always output some error log like
Cloning into 'project'...
\302\226\302\[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
stackoverflow answers suggest adding your key to ssh-agent and changing the SSH config for host github. The most annoying part of this issue is that even after you verify you've done the above 2 steps correctly and that ssh access to github works fine with ssh-agent -l
and ssh [email protected]
, the problem still persists.
It just seems like the git bash is unable to clone repos using ssh directly using git clone
for some reason. To clone a remote repo, I have to initialize an empty git repo, add remote as origin, and then pull, i.e.
mkdir project && cd project
git init
git remote add origin [email protected]:user/project.git
git pull origin master
Maybe I'm just missing something obvious but until then, I'm posting this gist to make sure I dont waste 1 hour of my life again the next time I encounter this problem.
I just hit this, and it's due to using Ctrl+Shift+v (muscle memory from linux), which in git bash inserts a "Start of Guarded Area" control character. This is the \302\226 sequence.
You can change git bash options to allow that shortcut for pasting by right clicking on the header and in Options/Keys checking "Ctrl+Shift+letter shortcuts".
See here, here, and here.