【问题标题】:Configuring SSH for git为 git 配置 SSH
【发布时间】:2014-11-04 21:43:50
【问题描述】:

我昨天发布了这个,但我已经取得了一些进展。原来我的IP地址被服务器列入黑名单。不过我还是遇到了一些麻烦。

当我运行“ssh -vvv git@gitlab.cs.myschool.edu”时,我得到了这个:

debug3: authmethod_is_enabled publickey
debug1: Next authentication method: publickey
debug1: Trying private key: /.ssh/id_rsa
debug3: no such identity: /.ssh/id_rsa: No such file or directory
debug1: Trying private key: /.ssh/id_dsa
debug3: no such identity: /.ssh/id_dsa: No such file or directory
debug1: Trying private key: /.ssh/id_ecdsa
debug3: no such identity: /.ssh/id_ecdsa: No such file or directory
debug1: Trying private key: /.ssh/id_ed25519
debug3: no such identity: /.ssh/id_ed25519: No such file or directory
debug2: we did not send a packet, disable method
debug3: authmethod_lookup keyboard-interactive

(这只是一个sn-p,似乎是问题的根源。整个日志在这里:http://pastebin.com/Ryx4NFwW

是说 /.ssh/id_rsa 不存在,但是:

PS C:\Users\Jonathan\.ssh> ls


    Directory: C:\Users\Jonathan\.ssh


Mode                LastWriteTime     Length Name
----                -------------     ------ ----
-a---         9/10/2014  10:58 PM         67 config
-a---          7/5/2014  10:39 PM       1675 github_rsa
-a---          7/5/2014  10:39 PM        402 github_rsa.pub
-a---         9/10/2014  11:14 PM       1679 id_rsa
-a---         9/10/2014  11:14 PM        397 id_rsa.pub
-a---         9/10/2014  10:17 PM        193 known_hosts

有人有什么想法吗?

编辑:我应该注意,如果我执行“ssh -vvv -i C:\Users\Jonathan.ssh\id_rsa git@gitlab.cs.myschool.edu”,它似乎可以正常工作。

Edit2:我刚刚注意到一些更奇怪的东西。在我上面发布的完整日志中,有这个部分:

debug3: load_hostkeys: loading entries for host "gitlab.cs.myschool.edu" from file "/.ssh/known_hosts"
debug3: load_hostkeys: found key type ECDSA in file /.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug3: load_hostkeys: loading entries for host "137.30.120.92" from file "/.ssh/known_hosts"
debug3: load_hostkeys: found key type ECDSA in file /.ssh/known_hosts:1
debug3: load_hostkeys: loaded 1 keys
debug1: Host 'gitlab.cs.uno.edu' is known and matches the ECDSA host key.
debug1: Found key in /.ssh/known_hosts:1
debug1: ssh_ecdsa_verify: signature correct

它可以从 known_hosts 文件中查找和读取。它与我的 id_rsa 密钥文件位于同一目录中。这真的很令人困惑,没有任何意义:(

编辑 3:我还尝试在 C:\Users\Jonathan.ssh\config 中创建一个配置文件(之前没有)并将其放入其中:

Host gitlab.cs.uno.edu
    IdentityFile C:\Users\Jonathan\.ssh\id_rsa

还尝试将主机更改为 uno.edu,但仍然不行。当我尝试运行 git clone 时,访问被拒绝。

【问题讨论】:

  • Windows 绝对不是我的东西,但是为什么 ssh 调试输出指向 /.ssh/whatever 而不是 C:/Users/Jonathan/.ssh/whatever
  • 我不知道!这是我试图弄清楚的一部分。 SSH 似乎找错地方了,我不知道为什么。
  • 能否也显示“.ssh/config”文件的内容?
  • 配置文件看起来不错。你用来访问服务器的终端是什么,command promptputtycygwingit bash (actually mingw32) 或者别的什么?形成日志,似乎是command prompt。您可以尝试使用git bash,它将在您配置的文件夹中查找私钥。

标签: git ssh


【解决方案1】:

您需要确保您的 %HOME% 环境变量值:因为与 git 一起打包的 openssh 将在 %HOME%/.ssh/ 中搜索 ssh 密钥,这将解释您看到的 /.ssh/ 如果 %HOME% 为空.

git-cmd.bat is supposed to set %HOME% properly

【讨论】:

  • 谢谢!我花了好几个小时试图解决这个问题。当我使用他们的安装程序安装 git 时,我将它安装到我的 D: 驱动器。在 D:\git\ 内有一个 .ssh 文件夹,它肯定会从那里读取我的密钥文件。 Git 现在可以成功运行了!顺便说一句,我没有 %HOME% 环境变量或 git-cmd.bat 文件。经历并设置它可能是正确的方法,但我很高兴它现在正在工作,我现在不会愚弄它。再次感谢您!
猜你喜欢
  • 2014-04-09
  • 1970-01-01
  • 1970-01-01
  • 2017-07-13
  • 1970-01-01
  • 2018-05-28
  • 1970-01-01
  • 2021-05-21
  • 1970-01-01
相关资源
最近更新 更多