突然有一天,发现github上git clone时,总down不下来代码,给出一句:RPC failed; curl 56 LibreSSL SSL_read: SSL_ERROR_SYSCALL, errno 54。
出现curl 56时,可能是git 缓存不够,按如下配置即可:
git config http.postBuffer 524288000
当出现errmo 54时,一定是SSL验证出现了问题。
所以有可能是配置不同平台的SSL时,将本地的id_rsa覆盖了,所以验证不通过。解决办法如下:
下面以配置Github的ssh key为例。
1. 生成ssh key时同时指定保存的文件名
> ssh-keygen -t rsa -f ~/.ssh/id_rsa.github -C "邮箱"
上面的id_rsa.github就是我们指定的文件名,这时~/.ssh
目录下会多出id_rsa.github
和id_rsa.github.pub
两个文件,id_rsa.github.pub
里保存的就是我们要使用的key。
2. 配置ssh config文件,如果文件不存在就创建
> vim ~/.ssh/config
# github
Host github.com
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa.github
# gitlab
Host gitlab.com
Hostname altssh.gitlab.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa.gitlab
# gitee
Host gitee.com
HostName gitee.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa.gitee
3. 测试ssh 是否配置成功,以Github为例
> ssh -T git@github.com
如果配置成功,则会显示:
Hi username! You’ve successfully authenticated, but GitHub does not provide shell access.
感谢JouyPub大神文章:http://www.jouypub.com/2018/0959250d1c900128efc07cf055dfeb62/