当前位置:   article > 正文

git报错ssh: connect to host github.com port 22: Connection timed out_git port22 c9nnection timed out

git port22 c9nnection timed out

昨天在使用VsCode向GitHub上传代码时,出现错误:(此前已经使用SSH的方式连接了GitHub仓库)

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

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

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

ssh -T git@github.com

发现报错:

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

端口连接超时。

查阅资料后,找到解决办法:

解决方案(亲测有效)

  1. 在C盘——用户——你的主机名文件夹中找到.ssh文件夹;(此前配置SSH时会生成该文件夹)
  2. 在.ssh文件夹中新建文件 config,不带后缀(可以新建文本文档,去掉.txt后缀)
  3. 使用notepad++(或其他方式)打开config文件,输入以下内容,保存后即可

  1. Host github.com
  2. User YourEmail(你的邮箱)
  3. Hostname ssh.github.com
  4. PreferredAuthentications publickey
  5. IdentityFile ~/.ssh/id_rsa
  6. Port 443
  1. 再次执行

ssh -T git@github.com

会出现以下提示,输入yes回车即可

  1. The authenticity of host '[ssh.github.com]:443 ([192.30.255.123]:443)' can't be established.
  2. RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
  3. Are you sure you want to continue connecting (yes/no)? yes
  4. Warning: Permanently added '[ssh.github.com]:443,[192.30.255.123]:443' (RSA) to the list of known hosts.

再次执行ssh -T git@github.com,发现验证通过

Hi Clare! You've successfully authenticated, but GitHub does not provide shell access.

完成以上步骤后,再次上传代码到GitHub就不会报错了

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/很楠不爱3/article/detail/562893
推荐阅读
相关标签
  

闽ICP备14008679号