当前位置:   article > 正文

git@github.com/nhn/raphael.git 解决 ssh: connect to host github.com port 22: Connection timed out_ssh: connect to host port 22:connection timed out

ssh: connect to host port 22:connection timed out

npm ERR! code 128 npm ERR! A git connection error occurred npm ERR! command git --no-replace-objects ls-remote ssh://git@github.com/nhn/raphael.git npm ERR! ssh: connect to host github.com port 22: Connection timed out npm ERR! fatal: Could not read from remote repository. npm ERR! npm ERR! Please make sure you have the correct access rights npm ERR! and the repository exists.

```

npm i 时报错  

真的无语了  各种百度搜索 终于总结以下步骤

```

1、检查 ping github.com

包证github 能ping通,

如果ping不通  

打开 目录 C:\Windows\System32\drivers\etc 中的 hosts文件

加 140.82.113.3  github.com 如图

再ping一次  

这一步是检查本机电脑能否访问github  如果不行 就要使用梯子

2、检查本机是否配置github 秘钥

查看SSH密钥是否存在

  1. 打开终端或命令提示符。
  2. 输入以下命令来查看.ssh目录下的文件:
    ls -la ~/.ssh
    你应该能看到类似id_rsaid_rsa.pub的文件,这些是SSH密钥对。

检查SSH密钥是否已添加到GitHub

  1. 登录到你的GitHub账户。
  2. 点击你的头像,然后选择 "Settings"(设置)。
  3. 在左侧菜单中,点击 "SSH and GPG keys"(SSH和GPG密钥)。
  4. 在这里,你应该能看到一个列表,列出了所有已添加的SSH密钥。检查列表,看是否有你的公钥(通常,公钥的文件名以.pub结尾)。

测试SSH连接。

  1. 打开终端或命令提示符。
  2. 输入以下命令:
    ssh -T git@github.com
    如果配置正确,你将看到一条消息,如 "Hi your_username! You've successfully authenticated, but GitHub does not provide shell access."(其中your_username是你的GitHub用户名)。

3、如果没有秘钥请配置github秘钥 再执行npm i

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

闽ICP备14008679号