Git 报错:Connection closed by remote host. fatal: Could not read from remote repository.

  • Post author:
  • Post category:其他




Git deploy 部署报错:ssh_exchange_identification: Connection closed by remote host. fatal: Could not read from remote repository.



1、背景:

今天部署到GitHub时,出现此错误。昨天还正常,今天突然这样。



2、详细错误信息:

[root@192 hexo]# hexo deploy
INFO  Validating config
INFO  Deploying: git
INFO  Clearing .deploy_git folder...
INFO  Copying files from public folder...
INFO  Copying files from extend dirs...
# 位于分支 master
无文件要提交,干净的工作区
ssh_exchange_identification: Connection closed by remote host
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
FATAL Something's wrong. Maybe you can find the solution here: https://hexo.io/docs/troubleshooting.html
Error: Spawn failed
    at ChildProcess.<anonymous> (/www/wwwroot/hexo/node_modules/hexo-util/lib/spawn.js:51:21)
    at ChildProcess.emit (node:events:513:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
[root@192 hexo]# 



3、解析错误信息:

错误信息翻译成中文后:

SSH交换识别:连接被远程主机关闭
致命的:无法从远程存储库读取。
请确保您拥有正确的访问权限
而且存储库已经存在。
致命错误。也许你可以在这里找到解决方案:https://hexo.io/docs/troubleshooting.html
错误:生成失败
	at ChildProcess.<anonymous> (/www/wwwroot/hexo/node_modules/hexo-util/lib/spawn.js:51:21)
    at ChildProcess.emit (node:events:513:28)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)

通过以上可知:

系统连接不到GitHub,因此无法用SSH密钥进行识别。 —-> 说明是网络问题。



4、实践探索 – 解决过程:

出现错误的时候,我又多次部署了几次,依然这样。

然后,我打开了手机热点,让电脑连接。

再次部署,部署成功。

之后我关闭热点,换回无线网。

再次部署,部署失败,无法连接,同样的错误。

再打开热点,再部署,这次用手机热点部署失败,依旧报这个错误。

关闭手机热点,再部署,部署成功…



5、总结

经过多次实践可知,这就是网络波动导致的问题,GitHub在国内连接本来就有时能连上有时连不上,而且我昨天部署过多次,都可以成功。这是今天突然发生的问题,而且我也没修改过其他东西,那么错误就不在自己这。



6、解决方案

  1. 尝试更换其他网络。
  2. 过一段时间再试。



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