问题一:解决 ssh: connect to host github.com port 22: Connection timed out

  1. 问题

    在使用hexo d向GitHub上传代码时,出现错误(此前已经使用SSH的方式连接了GitHub仓库并且hexo d没问题)

    1
    2
    3
    ssh: connect to host github.com port 22: Connection timed out
    Please make sure you have the correct access rights
    and the repository exists.

    首先输入以下命令检查SSH是否能够连接成功(ssh后面有空格)

    1
    ssh -T [email protected]   (或者ssh -vT [email protected],即显示详细信息)

    发现报错

    1
    ssh: connect to host github.com port 22: Connection timed out

    再使用下方命令,若成功,则使用下面的解决方法

    1
    ssh -T -p 443 [email protected]
  2. 解决方案
    在C盘——用户——找到.ssh文件夹;(此前配置SSH时会生成该文件夹)
    .ssh文件夹中新建文件 config,不带后缀(可以新建文本文档,去掉.txt后缀)
    使用ndd–(或其他方式)打开config文件,输入以下内容,保存后即可

    1
    2
    3
    4
    5
    6
    Host github.com
    User YourEmail(填你github注册邮箱)
    Hostname ssh.github.com
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa
    Port 443

    会出现提示后 ,输入yes回车即可,然后再次执行ssh -T [email protected],发现验证通过

    1
    Hi xxx! You've successfully authenticated, but GitHub does not provide shell access.
  3. 参考:

其他