git push / pull超时

时间:2009-04-16 18:25:31

标签: git timeout firewall

我不能从我的公司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

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

4 个答案:

答案 0 :(得分:13)

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

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

(这不是一个特定于git的问题,事实上你应该能够通过尝试使用telnet,nc或PuTTY等任何客户端连接到github.com端口22来证明问题:sshd通常会连接后立即打印带有版本号的横幅)

答案 1 :(得分:4)

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

windows的命令(或者我的情况下是cygwin)将是:route add <ip> <gateway>。 所以解决它的原因很简单:route add 207.97.227.239 192.168.0.1

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

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

答案 2 :(得分:0)

Mac用户:在安装OS X的更新版本后,我立即想到了这一点。在深入研究更改网络设置之前,我建议您进行额外的重启。这为我纠正了这个问题。

答案 3 :(得分:0)

增加计算机中的ssh连接超时。

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

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

private ObservableCollection<int> _myBoundPropertyCollection;
public ObservableCollection<int> MyBoundPropertyCollection { get { return _myBoundPropertyCollection; } set { _myBoundPropertyCollection = value; OnPropertyChanged(); } }
private void OnPropertyChanged([CallerMemberName] string propertyName = null)
{
    PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
public void TestCollection()
{
    new System.Threading.Thread(() =>
    {
        try
        {
            //MyBoundPropertyCollection = new ObservableCollection() { 0 }; //even so not throwing
            MyBoundPropertyCollection[0] += DateTime.Now.Second;
        }
        catch(Exception ex)
        {
        }
    }).Start();
}

<TextBlock Text="{Binding MyBoundPropertyCollection[0]"/>

通过vpn在Ubuntu 18.04.4 LTS上进行了测试。

here上查看更多信息