GITHUB 在git clone时出错,提示“Connection reset by … fatal: Could not read from remote repository.”

  • Post author:
  • Post category:其他

GITHUB 在git clone时出错,提示“Connection reset by XX.XXX.XXX.XXX port 22. fatal: Could not read from remote repository.”

在从github上clone工程时失败

现象:

  • 使用HTTP的方法,失败提示为:
    “fatal: unable to access
    ‘https://github.com/xxx/xxx.git/’: OpenSSL was built without SSLv3
    support”
  • 使用SSH的方法,失败提示为:
    “Connection reset by XX.XXX.XXX.XXX port 22 fatal:
    Could not read from remote repository.”

失败尝试:

以下是我尝试过无效的方法,但有些情况用了这些方法也许有效,现列出如下:

  • 忽略SSL Verification
    git config http.sslVerify “false”
  • 重新生成 SSH Keys
  • .ssh -p 222 用户名@服务端ip或ssh -l 222 用户名@服务端ip
  • 设置代理
    socks5:
    git config –global http.proxy ‘socks5://127.0.0.1:1080’
    git config –global https.proxy ‘socks5://127.0.0.1:1080’
    http/https:
    git config –global https.proxy http://127.0.0.1:1080
    git config –global https.proxy https://127.0.0.1:1080
  • 取消代理
    git config –global –unset http.proxy
    git config –global –unset https.proxy
  • 重置本机git设置git config –global credential.helper store
  • $ git init
  • 重新配置username等等
    $ git config –global user.name “yourname”
    $ git config –global user.email “your@email.com”

最终解决

我觉得真正产生作用的应该只有步骤4,只是我不能保证再复现之前的问题了:
1. 重新在git设置一下身份的名字和邮箱

  •  $ git config --global user.name "yourname"
     $ git config --global user.email "your@email.com“
    

2.删除 \.ssh 路径下的 known_hosts 文件
这是你当初注册github代码仓库时生成的ssh keys的路径,如果忘记,输入“$ ssh-keygen -t rsa -C “your@email.com” ssh keys生成命令时会提示已有id_rsa文件的存储路径。

3. 重新生成 \.ssh\id_rsa和 \.ssh\id_rsa.pub文件

  • $ ssh-keygen -t rsa -C "your@email.com"  #生成的id_rsa会覆盖原有key文件,一路回车,无需输入
    

4. 在git hub代码仓库端更新SSH keys
4.1 进入github设置界面
在这里插入图片描述
4.2 “New SSH key”
在这里插入图片描述
“Title” 随便取,“Key” 为 \.ssh\id_rsa.pub 内容。
获取方法:

  • 管理员打开命令提示符,cd到id_rsa.pub存储目录下
    
  • 输入"more id_ras.pub",右键选择后拷贝下来,填到github的ssh key里
    

5. 在C:\Windows\System32\drivers\etc\hosts文件添加一行 “192.30.253.113 github.com”
由于此hosts为系统文件,因此需要用管理员身份来修改。方法如下:

  • 管理员打开命令提示符,cd到C:\Windows\System32\drivers\etc
    
  • 输入“notepad hosts",添加“192.30.253.113 github.com”并保存      
    

原因

不是很确定,只知道可能是本地的访问权限问题

链接:
https://blog.csdn.net/ll951019/article/details/86220776.
https://www.cnblogs.com/wu-song/p/7985594.html


版权声明:本文为linda_5150原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。