6
votes

I've been having a bit of a head ache with trying to pull down a repository held in Gitlab. This is all done in Windows 8.1 on a Ubuntu VM by the way if that helps. I've added my public key in Gitlab and added my private key to ssh-agent ... all seems correct.

When I try and do a git pull this is where I run in to issues. It seems to me that Git is simply looking in the wrong location, my private key is stored in c/Users/Neil/.ssh but it seems as if git is looking in c/Users/Neil/.ssh/342/200/217 ...

C:\Users\Neil\code\homestead>git pull
no such identity: /c/Users/Neil/.ssh/id_rsa\342\200\217: No such file or directory
[email protected]'s password:

I've no idea why git would be looking there or am I thinking wrong about this? Can anyone shed some light on things for me?

2
Did you generated ssh keys from within the VM ? help.github.com/articles/generating-ssh-keysCiasto piekarz
No I didn't, I used a putty keygen, that shouldn't matter should it?Neil Kelsey

2 Answers

10
votes

GitLab itself isn't looking for your ssh keys: as a client, you are using ssh to contact GitLab, which means only openssh is looking for those keys.

It (openssh) will find them in:

  • %HOME%\.ssh (so check what the environment variable HOME is set to)
  • %HOME%\.ssh\config (where an IdentifiyFile directive can set a custom path for the ssh private key, so check if you have a .ssh/config file)

The OP Neil Kelsey confirms in the comments that the %HOME%\.ssh\config was causing some kind of interference.

And the push url seemed still referencing an https url.
A simple git remote set-url --push origin <ssh/url> fixed that.

0
votes

For macOS users, this problem can be fixed by running the following commands:

rm ~/.ssh/known_hosts # remove previous hosts
ssh-add -A # add all known SSH keys

After running the above commands, the problem should be fixed.