Git looking for my SSH key in the wrong location

半腔热情 提交于 2020-01-01 12:22:10

问题


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
git@git.mgmt.local'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?


回答1:


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.



来源:https://stackoverflow.com/questions/28784883/git-looking-for-my-ssh-key-in-the-wrong-location

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!