Git deploy 部署报错

本文最后更新于:2 个月前

ssh_exchange_identification: Connection closed by remote host. fatal: Could not read from remote repository.

背景:

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

详细错误信息:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[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]#

解析错误信息:

错误信息翻译成中文后:

1
2
3
4
5
6
7
8
9
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密钥进行识别。 ----> 说明是网络问题。

实践探索 - 解决过程:

  • 出现错误的时候,我又多次部署了几次,依然这样。
  • 然后,我打开了手机热点,让电脑连接。
  • 再次部署,部署成功。
  • 然后我关闭热点,换回无线网。
  • 再次部署,部署失败,无法连接,同样的错误。
  • 再打开热点,再部署,这次用手机热点部署失败,依旧报这个错误。
  • 关闭手机热点,再部署,部署成功…

总结

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

解决方案

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

Git deploy 部署报错
https://superlovelace.top/2022/11/29/Git-error/
作者
棱境
发布于
2022年11月29日
更新于
2023年11月19日
许可协议