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

逃离我推掉我的手 2022-12-14 08:47 220阅读 0赞

转载自:https://blog.csdn.net/weixin_39800144/article/details/104118750

问题

换了个wifi,git clone拉取代码就会报错,切回原来的wifi,又是可以的,反复尝试,最终确认,这个特定的wifi下,网页和命令行都不能访问github,甚是神奇。

  1. G:\mylearn\source-code>git pull
  2. ssh: connect to host github.com port 22: Connection timed out
  3. fatal: Could not read from remote repository.
  4. Please make sure you have the correct access rights
  5. and the repository exists.
  6. G:\mylearn\source-code>ssh -T git@github.com
  7. ssh: connect to host github.com port 22: Connection timed out

在这里插入图片描述

解决方案:

在C:\Users\wangzx.ssh目录下,也就是放这个的目录下:
在这里插入图片描述
创建一个文件,config,不需要后缀名,内容为:

  1. Host github.com
  2. User xxxyouremail@qq.com
  3. Hostname ssh.github.com
  4. PreferredAuthentications publickey
  5. IdentityFile ~/.ssh/id_rsa
  6. Port 443

添加完后如下:
在这里插入图片描述

  1. G:\mylearn\source-code>ssh -T git@github.com
  2. The authenticity of host '[ssh.github.com]:443 ([192.30.253.122]:443)' can't be established.
  3. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
  4. Are you sure you want to continue connecting (yes/no)? yes
  5. Warning: Permanently added '[ssh.github.com]:443,[192.30.253.122]:443' (RSA) to the list of known hosts.
  6. Hi lightClouds917! You've successfully authenticated, but GitHub does not provide shell access.
  7. G:\mylearn\source-code>ssh -T git@github.com
  8. Hi lightClouds917! You've successfully authenticated, but GitHub does not provide shell access.
  9. G:\mylearn\source-code>git pull
  10. Warning: Permanently added the RSA host key for IP address '[192.30.253.123]:443' to the list of known hosts.
  11. Already up-to-date.
  12. G:\mylearn\source-code>git pull
  13. Already up-to-date.

搞定!

发表评论

表情:
评论列表 (有 0 条评论,220人围观)

还没有评论,来说两句吧...

相关阅读