为git配置SSH

时间:2014-09-11 04:19:32

标签: git ssh

昨天我发布了这个,但我已经取得了一些进展。结果我的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

(那只是一个似乎是问题根源的片段。整个日志就在这里: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"它似乎工作正常。

编辑2:我刚注意到一些更奇怪的东西。在我上面发布的完整日志中,有以下部分:

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时,继续拒绝访问。

1 个答案:

答案 0 :(得分:3)

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

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