Git在错误的位置寻找我的SSH密钥 [英] Git looking for my SSH key in the wrong location

查看:228
本文介绍了Git在错误的位置寻找我的SSH密钥的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Gitlab中保存一个存储库时,有点头疼。如果有帮助的话,这些都是在Ubuntu VM的Windows 8.1上完成的。我在Gitlab中添加了我的公钥,并将我的私钥添加到了ssh-agent中...似乎都是正确的。



当我尝试做一个git pull时,我在哪里遇到问题。在我看来,Git只是在错误的位置查找,我的私钥存储在c / Users / Neil / .ssh中,但好像git正在c / Users / Neil / .ssh / 342/200 / 217 ...

  C:\ Users \Neil\code\homestead> git pull 
no这样的身份:/c/Users/Neil/.ssh/id_rsa\342\200\217:没有这样的文件或目录
git@git.mgmt.local的密码:

我不知道为什么git会在那里看,还是我在想这个错误?任何人都可以为我介绍一些事情吗?



N

解决方案

GitLab本身并不寻找你的ssh密钥:作为一个客户端,你使用ssh联系GitLab,这意味着只有openssh正在寻找这些密钥。



它(openssh)会发现它们:


  • %HOME%\.ssh (所以请检查一下环境变量 HOME 是否设置为)

  • %HOME%\.ssh\\ \\ config (其中IdentifiyFile指令可以为ssh私钥设置自定义路径,因此请检查是否有 .ssh / config 文件)



OP Neil Kelsey 确认在评论%HOME%\.ssh\config 导致了一些

并且推送网址似乎仍然引用了一个https url。

一个简单的 git remote set-url --push origin< ssh / url> 修正了这个问题。


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 about this wrong? Can anyone shed some light on things for me?

N

解决方案

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.

这篇关于Git在错误的位置寻找我的SSH密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆