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

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

问题描述

试图拉下 Gitlab 中的存储库时,我一直有些头疼.顺便说一句,如果有帮助的话,这一切都是在 Ubuntu VM 上的 Windows 8.1 中完成的.我已经在 Gitlab 中添加了我的公钥并将我的私钥添加到 ssh-agent ... 一切似乎都是正确的.

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.

当我尝试执行 git pull 时,这就是我遇到问题的地方.在我看来,Git 只是在寻找错误的位置,我的私钥存储在 c/Users/Neil/.ssh 但似乎 git 正在寻找 c/Users/Neil/.ssh/342/200/第217章……

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:UsersNeilcodehomestead>git pull
no such identity: /c/Users/Neil/.ssh/id_rsa342200217: No such file or directory
git@git.mgmt.local's password:

我不知道为什么 git 会在那里寻找,或者我对此有什么误解?谁能帮我解释一下?

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?

推荐答案

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

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.

它(openssh)会在以下位置找到它们:

It (openssh) will find them in:

  • %HOME%.ssh(因此请检查环境变量 HOME 设置为什么)
  • %HOME%.sshconfig(IdentifyFile 指令可以为 ssh 私钥设置自定义路径,因此请检查您是否有 .ssh/config 文件)
  • %HOME%.ssh (so check what the environment variable HOME is set to)
  • %HOME%.sshconfig (where an IdentifiyFile directive can set a custom path for the ssh private key, so check if you have a .ssh/config file)

OP Neil Kelsey 确认 在评论中指出 %HOME%.sshconfig 造成了某种干扰.

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

而且推送 url 似乎仍在引用 https url.
一个简单的 git remote set-url --push origin <ssh/url> 解决了这个问题.

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天全站免登陆