我们在使用git clone项目时候经常会 clone失败
fatal: unable to access 'https://github/xxxx/xxxx.git': Failed to connect to 127.0.0.1 port 8087: Connection refused
或是 fatal: unable to access 'https://github/zhayujie/chatgpt-on-wechat.git/': gnutls_handshake() failed: The TLS connection was non-properly terminated.
解决办法:
通过ssh连接GitHub
1. Linux安装ssh
sudo apt-get install ssh
ssh-keygen 会确认密钥的存储位置和文件名(默认是 .ssh/id_rsa),然后全部回车即可。
2. 创建秘钥文件
ssh-keygen -t rsa -C "你的github账号邮箱"
再点击三次回车键
3.将公钥添加到GitHub账户
(1)将id_rsa.pub文件内容全部复制;
(2)登陆到GitHub上,右上角小头像->Setting->SSH and GPG keys中,点击new SSH key。
4. ssh测试
ssh -T git@github
结果为:,表示配置成功。