解决git无法clone地址为https的库

原文链接:https://www.cnblogs.com/harrymore/p/8985058.html

一、问题描述

早上在学习《Spark快速大数据分析》的时候,需要下载书本的实例代码,于是用git clone一下给出的库:

https://github.com/databricks/learning-spark.git

结果,并不能成功克隆,最后的错误输出信息是“git https fatal: HTTP request failed”。

 

二、解决过程

上网找了一下,一种方案是用git:或者ssh:代替https:,譬如github官网给出的方案:https://help.github.com/articles/using-ssh-over-the-https-port/,按照这个去做而且成功了,然而并没什么卵用,出现了“Error: Permission denied (publickey)”,还是无法克隆。且罢。

 

于是还是继续用https链接,了解到原来git使用curl作为它的https传输客户端,需要设置一个环境变量:

export GIT_CURL_VERBOSE=1
https://github.com/databricks/learning-spark.git

还是有报错,首先是ping不通github.com,上网搜了一下可以设置为另一个地址:192.30.253.113,可以ping通,于是在/etc/hosts文件加上:

192.30.253.113 github.com

还有就是证书问题,设置一下:

git config --global http.sslverify true
git config --global http.sslCAPath /etc/pki/tls/certs

 

重新操作还是报错,这次是“failed to load from … CURLOPT_CAPATH”以及“NSS error -12286”,猜测是curl的配置问题。

最后通过一篇文章了解到应该是cipher的问题,https://bugs.centos.org/view.php?id=5620,其中有评论说到:

Yes there is and this is not a bug, it's just that in the latest version curl doesn't have RC4-SHA enabled by defaul.

按照里面说的方法测试了一下:

curl --cipher rsa_rc4_128_sha https://github.com/databricks/learning-spark.git

然后。。。表示没有这种cipher,最后提示“curl: (35) SSL connect error”,通过这个信息,找到另外一篇博文,说需要先升级nss:

yum update nss

升级完之后,重新克隆目标库,终于搞定!!!

 

三、参考

1. git and HTTPS (fatal: HTTP request failed)

2. Using SSH over the HTTPS port

3. curl: (35) SSL connect error的解决方法

(完)

posted @ 2018-05-03 14:07  大师兄啊哈  阅读(48979)  评论(0编辑  收藏  举报