问题描述
在执行hexo d
发布文章时候,出现错误:
error fatal: unable to access ‘https://github.com/huanyouchen/huanyouchen.github.io.git': gnutls_handshake() failed: The TLS connection was non-properly terminated.
![git-error](https://img-blog.csdnimg.cn/img_convert/2ac29d0a6081c6d48a6f6a8bff18606c.png)
git-error
具体原因还不清楚,搜索一番后看到好几个都是用openssl解决的,于是按着试试,果然也解决了。方法主要参考这两篇文章:
使用 Git 同步时出现ssl错误
git 无法clone踩坑实录
在试的过程中我也遇到了另外两个问题,因此也记录一下。
解决方法
安装编译环境:
1
2
3
4
5
6
7
|
sudo apt-get update
sudo apt-get install build-essential fakeroot dpkg-dev libcurl4-openssl-dev
sudo apt-get build-dep git
mkdir ~/git-openssl
cd ~/git-openssl
sudo apt-get source git
dpkg-source -x git_2.17.1-1ubuntu0.4.dsc # git版本不同注意根据自己的更改
|
在第三个命令执行时,我遇到了一个错误,提示如下:
正在读取软件包列表... 完成
E: 您必须在 sources.list 中指定代码源(deb-src) URI
|
解决方法参考:打开Ubuntu中的“软件和更新”-》Ubuntu软件-》把“可从互联网下载”中的最后一个:源代码勾选上。然后就可以顺利执行第三步了。
使用sed命令,把debian/control中所有的libcurl4-gnutls-dev改为libcurl4-openssl-dev
cd git-2.17.1/ # 进入目录
sudo sed -i 's/libcurl4-gnutls-dev/libcurl4-openssl-dev/g' debian/control
|
删除 debian/rules 中的TEST=test行
vim debian/rules
原内容中的TEST=test行如下:
LDFLAGS :=$(shell dpkg-buildflags --get LDFLAGS)
TEST =test
OPTS =NO_OPENSSL=1 prefix=/usr gitexecdir=/usr/lib/git-core \
将其中的TEST=test行删掉
|
编译
sudo apt-get install libcurl4-openssl-dev
sudo dpkg-buildpackage -rfakeroot -b -uc -us # add "-uc -us" to avoid error "gpg: No secret key"
|
安装
sudo dpkg -i ../git_2.17.1-1ubuntu0.4_amd64.deb #注意是在上一级目录
|
做好以上的这几步,网上的教程就结束了,我本来以为就已经弄好了,然后再次hexo d的时候,还是会出错,但是这次错误变成了SSL_ERROR_SYSCALL:
Error: fatal: unable to access 'https://github.com/huanyouchen/huanyouchen.github.
io.git':LibreSSL SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443
|
然后再搜这个SSL_ERROR_SYSCALL的解决方法时候,网上的各种说法都有,,然后开始自己摸索,不一定适合其他人,但是我的问题最终解决了。
思路来源:
https://github.com/angular/angular-phonecat/issues/212
https://segmentfault.com/q/1010000013461740
首先设了代理(不知道这一步有没有用,当时试了一下):
http.proxy=http://127.0.0.1:1080
|
然后到GitHub网站上,把我的SSH Keys设置那里,加入了我的id_rsa.pub,然后ssh -T git@github.com
验证一下,提示:
Hi huanyouchen! You've successfully authenticated, but GitHub does not provide shell access.
|
再然后进入hexo网站的根目录,找到hexo的配置文件_config.yml
,在配置文件中的deploy那一项从原来HTTPS的改成SSH的。
deploy:
type: git
#repo: https://github.com/huanyouchen/huanyouchen.github.io.git
repo: git@github.com:huanyouchen/huanyouchen.github.io.git
brance: master
|
现在终于成功了。
![git-error-solve](https://img-blog.csdnimg.cn/img_convert/7227b242a5dbf11cdf849de6b3f40d31.png)
git-error-solve