wsl ubuntu git clone 失败

wsl ubuntu 使用 git clone 时失败

wslgit clone 失败,错误如下

1
2
3
hekai@thinkpad-l14:~$ git clone https://github.com/msdemt/docker-centos7-slurm-cluster.git
Cloning into 'docker-centos7-slurm-cluster'...
fatal: unable to access 'https://github.com/msdemt/docker-centos7-slurm-cluster.git/': GnuTLS recv error (-110): The TLS connection was non-properly terminated.

参考:
https://zhuanlan.zhihu.com/p/624555732

重新安装下 git

1
2
3
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git

之后可以 git clone 成功了,但是过一段时间,又 git clone 出现了相同的问题

最终解决:配置 git 代理

1
git config --global http.proxy socks5://127.0.0.1:7890

git clone 失败,原因 linux 子系统无法使用 127.0.0.1 访问 windows 系统上的服务

参考:
https://learn.microsoft.com/zh-cn/windows/wsl/networking

在 linux 子系统 ubuntu 中执行

1
cat /etc/resolv.conf
1
2
3
4
5
hekai@thinkpad-l14:~$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.22.192.1

复制 nameserver 后面的地址

linux 子系统中使用该地址访问 windows 上的服务,所以 git 代理改为如下内容

1
git config --global http.proxy socks5://172.22.192.1:7890

git clone 成功。

Built with Hugo
主题 StackJimmy 设计