问题描述:ssh:connect to host github.com port 22:Connection timed out

问题原因:可能是网络下修改防火墙的问题,导致阻塞了一些端口

解决方案:

步骤1:

ssh -T git@github.com

作用是验证当前的SSH key是不是正常工作

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

看到上述内容,表示当前的SSH key是正常工作的,若不是正常工作,则需要重新生成并添加SSH key

步骤2:若上述操作成功,则用HTTP协议代替SSH,需要将配置文件中的URL改为HTTP

git config --local -e

在git中输入上述代码,修改:

url = git@github.com:username/repo.git

为:

url = https://github.com/username/repo.git

这样就能push了,不会timeout了。该方法同样适用于gitlab。

相关文章:

  • 2022-12-23
  • 2021-08-19
  • 2021-09-16
  • 2021-04-03
  • 2022-12-23
  • 2022-03-09
  • 2021-06-17
  • 2022-12-23
猜你喜欢
  • 2022-01-02
  • 2022-12-23
  • 2022-12-23
  • 2021-07-18
  • 2021-07-20
  • 2021-12-23
  • 2021-09-29
相关资源
相似解决方案