git 推/拉超时

发布于 2024-07-17 17:17:59 字数 290 浏览 6 评论 0原文

我无法从我的公司 vpn git push/pull 到 github:

git push origin master
ssh: connect to host github.com port 22: Connection timed out
fatal: The remote end hung up unexpectedly

我认为这是一个防火墙问题,b/c 如果我断开与 vpn 的连接,它就可以工作。 我能做些什么来解决这个问题吗? 或者当我需要推/拉时我是否卡在与VPN的连接上?

I can't git push/pull to github from my corporate vpn:

git push origin master
ssh: connect to host github.com port 22: Connection timed out
fatal: The remote end hung up unexpectedly

I assume this is a firewall issue, b/c if I disconnect from the vpn it works. Is there anything I can do to work around it? Or am I stuck disconnecting from the vpn when I need to push/pull?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

dawn曙光 2024-07-24 17:17:59

不确定您使用的是哪种类型的 VPN,但这种效果通常是由于 VPN 设置通过 VPN 路由所有流量所致。 您可以通过更新路由表以通过以太网(我假设)接口而不是通过 VPN 将流量路由回 github 来解决此问题。

例如 route add 65.74.177.129 eth0 将通过 eth0 将流量路由到 github。 这是Linux语法; Windows 也有一个大致相似的“route”命令。

(这并不是真正的 git 特定问题,事实上,您应该能够通过尝试使用任何客户端(例如 telnet、nc 或 PuTTY)连接到 github.com 端口 22 来演示该问题:sshd 通常会打印一条横幅连接后立即显示其版本号)

Not sure which type of VPN you're using, but this sort of effect is usually due to the VPN setup routing all your traffic over the VPN. You can work around that by updating your routing tables to route traffic to github back over your Ethernet (I assume) interface rather than over the VPN.

For example route add 65.74.177.129 eth0 will route traffic to github over eth0. This is the Linux syntax; Windows has a "route" command as well that is broadly similar.

(This isn't really a git-specific problem, and in fact you should be able to demonstrate the problem by trying to connect to github.com port 22 with any client such as telnet, nc or PuTTY: sshd will usually print a banner with its version number as soon as you connect)

许你一世情深 2024-07-24 17:17:59

我遇到了完全相同的问题,添加 github 的路由也解决了我的问题。

Windows(或我的情况下是 cygwin)的命令是:route add; <网关>
所以为我解决这个问题的方法很简单:route add 207.97.227.239 192.168.0.1

请注意我使用的 github.com 的 IP 与两年前 araqnid 的 IP 不同。 :)

如果您不确定添加的路由在一段时间后是否仍然有效,只需键入(在 Windows 或 cygwin 上)tracert github.com 即可查看数据包的路由位置。 如果第一个命中似乎位于您的公司内,则您添加的路线不再有效,您需要添加新路线。

I had exactly the same problem and adding a route for github solved my issues as well.

The command for windows (or cygwin in my case) would be: route add <ip> <gateway>.
So what solved it for me was simply: route add 207.97.227.239 192.168.0.1.

Please note the different IP for github.com I used in comparison with the one araqnid had, two years ago. :)

If you are not sure whether your added route still works after some time, just type (on windows or cygwin) tracert github.com to see where the packets get routed. If the first hit seems to be located within your company, the route you added is not valid anymore and you would need to add a new route.

巷子口的你 2024-07-24 17:17:59

Mac 用户:我在安装更新版本的 OS X 后立即发生了这种情况。在您深入研究更改网络设置之前,我建议您重新启动一次。 这为我纠正了这个问题。

Mac users: This occurred for me immediately after installing an updated version of OS X. Before you dig too deep into changing network settings I suggest doing an extra restart. This corrected the issue for me.

情定在深秋 2024-07-24 17:17:59

增加机器中的 ssh 连接超时。

创建 ~/.ssh/config 文件(如果不存在)。

将 SSH ServerAliveInterval ServerAliveCountMax 设置添加到文件中,例如:

Host *
     ServerAliveInterval 86400
     ServerAliveCountMax 4

通过 vpn 在 Ubuntu 18.04.4 LTS 上测试。

如需了解更多信息,请访问此处

Increase the ssh connection timeout in your machine.

Create ~/.ssh/config file (if it doesn't exist).

Add SSH ServerAliveInterval ServerAliveCountMax settings into the file, eg:

Host *
     ServerAliveInterval 86400
     ServerAliveCountMax 4

Tested on Ubuntu 18.04.4 LTS through vpn.

See more at here

初见终念 2024-07-24 17:17:59

我发现使用 git://github.com/pre-commit/pre-commit-hooks 等 URL 的 github.com 存储库会发生这种情况。 将它们切换到 git+ssh:// 为我解决了这个问题; 例如,上面的 URL 变为 git+ssh://[email protected] /预提交/预提交挂钩

这可能需要您 首先在 github 中设置 ssh 密钥

如果您不想手动更改所有 URL,可以配置 git 来交换它们:

git config --global url."[email protected]:".insteadOf "git://github.com/"

I see this happening with github.com repositories that use git:// URLs like git://github.com/pre-commit/pre-commit-hooks. Switching them to git+ssh:// fixed it for me; for example, the above URL becomes git+ssh://[email protected]/pre-commit/pre-commit-hooks.

This may require you to set up ssh keys in github first.

If you don't want to manually change all your URLs, you can configure git to swap them:

git config --global url."[email protected]:".insteadOf "git://github.com/"
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文