git报错 failed: The TLS connection was non-properly terminated

电脑不知道为什么不能git clone,报错:

$ git clone https://github.com/ShixiangWang/VSHunter
正克隆到 'VSHunter'...
fatal: unable to access 'https://github.com/ShixiangWang/VSHunter/': gnutls_handshake() failed: The TLS connection was non-properly terminated.

查了下需要使用libcurl4-openssl-dev替换gnutls对git进行编译。

sudo apt-get install build-essential fakeroot dpkg-dev
mkdir ~/git-openssl
cd ~/git-openssl
sudo apt-get source git
sudo apt-get build-dep git

如果出现找不到源代码的报错,使用命令sudo vim /etc/apt/sources.list打开文件并取消带deb_src那一行的注释,保存后运行sudo apt update,然后再执行上面最后一条命令
接着:

sudo apt-get install libcurl4-openssl-dev
sudo dpkg-source -x git_2.17.0-1.dsc
cd git_2.17.0 #实际版本可能不同

然后编辑文件debian/control,使用命令sudo vim deebian/control,将全部的libcurl4-gnutls-dev改为libcurl4-openssl-dev 。
接着运行命令:

sudo dpkg-buildpackage -rfakeroot -b
# (if it's failing on test, you can remove the line TEST=test from the file debian/rules)
sudo  dpkg -i  ../git_2.17.0-1_amd64.deb 

一般情况下到这就修复了这个问题了,但此时我还是不能进行克隆。

$ git clone https://github.com/ShixiangWang/VSHunter.git
正克隆到 'VSHunter'...
fatal: unable to access 'https://github.com/ShixiangWang/VSHunter.git/': OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to 127.0.0.1:45077

通过搜索,我搞明白 git也要配置网络代理,而我使用了蓝灯,代理就出问题了。
进行以下配置:

git config --global http.proxy 'socks5://127.0.0.1:45077'
git config --global https.proxy 'socks5://127.0.0.1:45077'
git config --global http.proxy 'http://127.0.0.1:45077'
git config --global https.proxy 'http://127.0.0.1:45077'

注意端口号也设置代理的端口号,不同vpn,不同系统端口号可能不同。

现在我就能够正常克隆了:

$ git clone https://github.com/ShixiangWang/VSHunter.git
正克隆到 'VSHunter'...
remote: Enumerating objects: 95, done.
remote: Counting objects: 100% (95/95), done.
remote: Compressing objects: 100% (57/57), done.
remote: Total 591 (delta 54), reused 64 (delta 34), pack-reused 496
接收对象中: 100% (591/591), 149.13 MiB | 848.00 KiB/s, 完成.
处理 delta 中: 100% (361/361), 完成.

一些代理相关命令:
#查看代理
git config --global http.proxy

#删除代理
git config --global --unset http.proxy
git config --global --unset https.proxy

取消curl代理

unset http_proxy
unset https_proxy

如果curl也需要设置代理,配置文件~/.curlrc

格式

proxy = server1.cyberciti.biz:3128
proxy-user = “foo:bar”

如我使用下面的内容就可以和 git的http代理统一起来了

proxy = http://127.0.0.1:45077

参考文章:

解决git gnutls_handshake失败
github 遇到 OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443问题

作者:王诗翔
链接:https://www.jianshu.com/p/72b9903a05f4
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

  • 21
    点赞
  • 83
    收藏
    觉得还不错? 一键收藏
  • 12
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 12
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值