
本人是在 win10 系统下使用在 https://git-scm.com/download/win 下载的 git 命令行。 在使用 ssh -vT [email protected] 后,输出如下:
$ ssh [email protected] -vT OpenSSH_7.1p2, OpenSSL 1.0.2h 3 May 2016 debug1: Reading configuration data /c/Users/DaCong/.ssh/config debug1: /c/Users/DaCong/.ssh/config line 1: Applying options for github.com debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to ssh.github.com [182.239.95.136] port 443. debug1: Connection established. debug1: identity file /c/Users/DaCong/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.1 ssh_exchange_identification: Connection closed by remote host 从 debug 的结果来看,应该是没有找到 key 文件,可是,我在 ~/.ssh/ 下执行 ls -la 之后,输出如下:
total 34 drwxr-xr-x 1 DaCong 197609 0 7 月 5 09:47 ./ drwxr-xr-x 1 DaCong 197609 0 7 月 5 23:10 ../ -rw-r--r-- 1 DaCong 197609 53 7 月 5 08:43 config -rw-r--r-- 1 DaCong 197609 1679 7 月 5 09:19 id_rsa -rw-r--r-- 1 DaCong 197609 392 7 月 5 09:19 id_rsa.pub 应该说我是有密钥文件的,而且也有读写权限,为什么就成了找不到 key 了呢? 因为这个问题,我提交文件的时候用的是 https , clone 也是,每次更新 hexo 博客都要输入密码,非常麻烦。 还有,我已经在 github 中提交了 id_rsa.pub 。 我已经在 google 上搜索过了,相似的问题的解决方案并没有起作用,所以来 V2EX 提问,希望能够解决问题。
说明一下,贴出config文件:
Host github.com Hostname ssh.github.com Port 443 如果不写这个config,返回的结果是这样的
$ ssh -vT [email protected] OpenSSH_7.1p2, OpenSSL 1.0.2h 3 May 2016 debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to github.com [182.239.95.136] port 22. debug1: Connection established. debug1: identity file /c/Users/DaCong/.ssh/id_rsa type 1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_rsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_dsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_dsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_ecdsa type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_ecdsa-cert type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_ed25519 type -1 debug1: key_load_public: No such file or directory debug1: identity file /c/Users/DaCong/.ssh/id_ed25519-cert type -1 debug1: Enabling compatibility mode for protocol 2.0 debug1: Local version string SSH-2.0-OpenSSH_7.1 ssh_exchange_identification: read: Connection reset by peer 因此,我是在参考了 https://help.github.com/articles/using-ssh-over-the-https-port/ 后,加入了config @aec4d @Citrus @xing393939
1 xing393939 2016-07-06 07:40:56 +08:00 via iPhone 看下你 windows 的 c 盘有 c:/Users/DaCong/.ssh/吗,另外 你那 debug 信息好像还在找 https 的证书? |
2 aec4d 2016-07-06 08:02:01 +08:00 并不是没有找到该文件 identity file /c/Users/DaCong/.ssh/id_rsa type 1 你可以执行 ssh -T [email protected] -vvv 查看更详细的信息 同时贴出你的 config 文件看看 最后你连接的是 ssh.github.com:443 这果断是不科学的 |
3 aec4d 2016-07-06 08:13:14 +08:00 另外 你上面显示连接的 ip 是中国移动的 ip....... 如果本来就被中间人 连不上也是情理之中的了 |
4 Citrus 2016-07-06 08:36:50 +08:00 via iPhone debug1: Reading configuration data /etc/ssh/ssh_config debug1: Connecting to ssh.github.com [182.239.95.136] port 443. 你在逗我么?写了配置强制 ssh 去连 HTTPS 端口??? |
5 DaCong OP |
7 yangtukun412 2016-07-06 09:44:24 +08:00 via Android config 里加上 IdentityFile ~/.ssh/id_rsa ,另外文件权限应该要 600 才可以。 |
8 aec4d 2016-07-06 09:54:20 +08:00 @DaCong 是因为你用的网络被中间人了 你可以查那个 IP 是移动的不是 github 的 当然会握手协商失败 挂代理吧:D 或者你试一下添加 hosts 192.30.253.112 github.com |
9 aec4d 2016-07-06 09:56:00 +08:00 ssh -T [email protected] -vvv 直接这样测试 |
10 lonelinsky 2016-07-06 10:07:59 +08:00 ~/.ssh/id_rsa 的权限太开放了吧,改为 400 或者 600 试试… |
11 Citrus 2016-07-06 10:15:00 +08:00 |
12 raysonx 2016-07-06 10:15:57 +08:00 @aec4d 正解。 根据楼主的日志, github.com 解析到了 182.239.95.136 ,这个 IP 是中国移动的 SNI 缓存服务器: IPIP.net 数据 您输入的 IP: 182.239.95.136 中国香港 移动 结论就是,楼主的运营商(移动)使用 DNS 劫持将 github.com 劫持到了移动的缓存服务器。 |
13 skydiver 2016-07-06 10:16:32 +08:00 via Android key 权限必须是 600 |
15 lslqtz 2016-07-06 14:43:05 +08:00 via iPhone 又得到了个新缓存服务器。 |
16 tomorrowin 2018-03-18 22:26:08 +08:00 THIS post helped me out !!!!thank you sooooooooooo much!!!!! |
17 shuirong1997 2020-01-20 22:12:50 +08:00 help me too, thank you, guys. |