我在代理下,我在相当长的一段时间内成功地推进。 现在我突然不能进入git了。 我已经设置了RSA密钥和代理,并仔细检查了它们,没有效果,git抛出了页面标题中显示的错误。


当前回答

执行:

nc -v -z <git-repository> <port>

你的输出应该是这样的:

"Connection to <git-repository> <port> port [tcp/*] succeeded!"

如果你得到:

connect to <git-repository> <port> (tcp) failed: Connection timed out

您需要编辑~/。ssh / config文件。添加如下内容:

Host example.com
Port 1234

其他回答

我也遇到了同样的问题,但找不到有效的解决方案。我在设置本地服务器时遇到了这个问题,git无法通过我的代理网络连接,但我的工作站可以。这是我运行命令时的输出 ssh -vT git@github.com

ubuntu@server:~$ ssh -vT git@github.com
OpenSSH_7.2p2 Ubuntu-4ubuntu2.8, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /home/ubuntu/.ssh/config
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to github.com [13.234.176.102] port 22.

因此,我尝试通过编辑配置文件~/使用通过HTTPS端口建立的SSH连接。Ssh /config但是没有效果。

Host github.com
 Hostname ssh.github.com
 Port 443

最后,我找到了这篇文章,解决并暴露了真正的问题。

# github.com
Host github.com
    Hostname ssh.github.com
    ProxyCommand nc -X connect -x <PROXY-HOST>:<PORT> %h %p
    Port 443
    ServerAliveInterval 20
    User git

这是我的配置文件,现在git通过ssh工作得很好!

当我不小心切换到客户wifi网络时,我得到了这个错误。不得不切换回默认的wifi网络。

在我的情况下,这个问题是由我前一天在路由器上更改的设置引起的。 所以在我的路由器上,我只需要将隔离设置恢复为禁用,它已经解决了我的问题。

在与Ludder类似的失败模式中,当我还没有登录到正确的公司VPN时,我就得到了这个错误。facepalm指:

如果您在windows中,移动到您存储ssh密钥的目录,然后再试一次,这对我有用。