无法使用 git@github.com 推送/拉取代码, 是抽风了还是被墙了?

2022 年 4 月 25 日
 beginor

这几天突然发现无法使用 git@github.com:user/repo 推送 /拉取代码了, 一开始以为是 ssh_key 过期的问题, 重新生成了新的 ssh_key , 发现还是不行, 提示如下:

git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
  (use "git push" to publish your local commits)

nothing to commit, working tree clean

git push
ssh: connect to host github.com port 22: Operation timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
5817 次点击
所在节点    GitHub
29 条回复
villivateur
2022 年 4 月 25 日
被墙了
ZE3kr
2022 年 4 月 25 日
据说 443 端口也可以 ssh ,楼主试试
beginor
2022 年 4 月 25 日
@ZE3kr 很早就就不能用 https 推送了,后来才迁移到 ssh 的
wszzh
2022 年 4 月 25 日
遇到一样的情况,后来配置了 SSH 代理解决了。https://www.wuyiting.cn/blog/Correct%20way%20to%20set%20git%20proxy
windplume
2022 年 4 月 25 日
我昨天是改了 http(s).proxy 才能连上
Hack3rHan
2022 年 4 月 25 日
配个代理就知道是不是墙了,而且 Operation timed out 已经很明显了。
MrCurly
2022 年 4 月 25 日
Host github.com
Hostname ssh.github.com
Port 443
MrCurly
2022 年 4 月 25 日
试试
tinkerer
2022 年 4 月 25 日
ssh 流量是墙重点关照对象
beginor
2022 年 4 月 25 日
@MrCurly 谢谢, 这个确实可行, 且用且珍惜
beginor
2022 年 4 月 25 日
@wszzh 谢谢, 这个也可行, 必过必须是 http/https 代理, 不能是 socks5 代理
mschultz
2022 年 4 月 25 日
Host github.com
Hostname ssh.github.com
Port 443
User git
ProxyCommand nc -X 5 -x 127.0.0.1:1080 %h %p

SOCKS5 代理是可以的。我这里的 nc 是 macOS 自带的 /usr/bin/nc, 别的系统上的 netcat 可能参数稍微不同但应该大同小异。
AllenHua
2022 年 4 月 25 日
毛遂自荐了属于是 https://www.v2ex.com/t/843383#reply47
fzls
2022 年 4 月 25 日
用这个,感觉是快开会了,墙的强度加大了
前天家里电脑也遇到了,当时在 Stack Overflow 找到个解决方案 https://stackoverflow.com/a/52817036
与 7 楼基本一样
silentsky
2022 年 4 月 25 日
昨天我也遇到这个问题
beginor
2022 年 4 月 25 日
@mschultz
@AllenHua

学习了, 回去就把 connect 删了 😂
jdjingdian
2022 年 4 月 25 日
最近一直遇到 ping 不通 github.com ,用站长工具多地点 ping 发现全国很多地方都 ping 不通,有个别 ip 是可以 ping 通,我就先写 hosts 来用了
wszzh
2022 年 4 月 25 日
@beginor socket 代理协议可以的哦,改参数 -H 改为 -S ,下面是我的配置。
Host github.com
User git
ProxyCommand connect -S 127.0.0.1:7890 %h %p
详情可以参照这个帖子 https://v2ex.com/t/841032#reply17
wszzh
2022 年 4 月 25 日
总喜欢把 socks 打成 socket 😂
AllenHua
2022 年 4 月 25 日
@beginor #16 macOS 和 大部分 Linux Distro 都自带 /usr/bin/nc 的

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/849046

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX