Hexo+Github博客:执行 hexo d 时,提示连接Github的22端口超时

本文详细解析了在使用GitHub时遇到SSH连接超时的问题,提供了具体的错误信息及解决步骤,包括重新配置密钥和更新SSH公钥。

@Author:CSU张扬
@Email:csuzhangyang@gmail.com or csuzhangyang@qq.com
@我的网站: https://www.faker.top

问题预览:

ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

1.1 问题描述

具体错误信息如下:
在这里插入图片描述

ssh: connect to host github.com port 22: Connection timed out
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> (F:\Program Files\hexo\node_modules\hexo-util\lib\spawn.js:51:21)
    at ChildProcess.emit (events.js:210:5)
    at ChildProcess.cp.emit (F:\Program Files\hexo\node_modules\cross-spawn\lib\enoent.js:34:29)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)

一开始我把目光聚焦在后面的 Error: Spawn failed 上,但是没有学过前端的我并看不懂。
但是,真正的错误是在上面一部分信息里。

ssh: connect to host github.com port 22: Connection timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

ssh:连接到主机github.com端口22:连接超时
致命:无法从远程存储库读取。
请确保您具有正确的访问权限,并且存储库存在。

1.2 解决办法

直接暴力解决:重新配置密钥

  1. git bash 窗口依次输入:(注意:双引号里改为你的Github的名字和邮箱)

    git config --global user.name "MagicConchCpp"
    
    git config --global user.email "csuzhangyang@gmail.com"
    
  2. 生成新秘钥:

    ssh-keygen -t rsa -C "csuzhangyang@gmail.com"
    

    选择文件路径,然后遇到下面这个直接回车。

    $ ssh-keygen -t rsa -C "csuzhangyang@gmail.com"
    Generating public/private rsa key pair.
    Enter file in which to save the key (/c/Users/lenovo/.ssh/id_rsa):
    

    文件已经存在,是否重写?输入 y ,回车。

    /c/Users/lenovo/.ssh/id_rsa already exists.
    Overwrite (y/n)? y
    

    然后设置密码什么的,不用管,直接两下回车。

    Enter passphrase (empty for no passphrase):
    Enter same passphrase again:
    Your identification has been saved in /c/Users/lenovo/.ssh/id_rsa.
    Your public key has been saved in /c/Users/lenovo/.ssh/id_rsa.pub.
    The key fingerprint is:
    
  3. 新秘钥保存在 /c/Users/lenovo/.ssh/id_rsa.pub
    打开这个文件,复制其中的的内容。
    github 中,打开 setting -> SSH and GPG keys 。删除原来的,把新的复制进去,即解决。重新执行 hexo d

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值