【问题标题】:Gitlab SSH connection is timed out, but using HTTP(S) works fineGitlab SSH 连接超时,但使用 HTTP(S) 工作正常
【发布时间】:2021-01-07 02:18:10
【问题描述】:

提示:我的机器和 Gitlab 上都完美配置了 SSH 密钥,所以显然这不是身份验证问题,而是连接问题。

当我连接到我的家庭网络并尝试通过 SSH (ssh -v git@gitlab.com) 连接到 Gitlab 时,连接超时并失败。 然后进程尝试再次连接,现在使用 IPv4,然后连接成功(等待几分钟后),这是输出:

OpenSSH_7.4p1 Debian-10+deb9u7, OpenSSL 1.0.2u  20 Dec 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to gitlab.com [2606:4700:90:0:f22e:fbec:5bed:a9b9] port 22.
debug1: connect to address 2606:4700:90:0:f22e:fbec:5bed:a9b9 port 22: Connection timed out
debug1: Connecting to gitlab.com [172.65.251.78] port 22.
debug1: Connection established.

但是,如果我连接到任何其他网络,则连接成功,导致以下输出:

OpenSSH_7.4p1 Debian-10+deb9u7, OpenSSL 1.0.2u  20 Dec 2019
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to gitlab.com [172.65.251.78] port 22.
debug1: Connection established.

显然这是我的家庭网络或 Gitlab 上的问题,但我已经尝试了所有方法并尝试了很多可能的解决方案,但没有成功。

非常感谢任何帮助。

【问题讨论】:

  • 您可以将系统配置为首选 ipv4(而不是 ipv6),但这对这里显然发生的任何其他网络过滤都无济于事。有关 Linux 上的 ipv4/ipv6 优先级,请参阅serverfault.com/questions/93717/…
  • 如果您的网络支持 IPv6,那么您需要弄清楚它为什么不工作或被过滤。如果您的网络不支持 IPv6,您需要弄清楚为什么您会获得有效的全球 IPv6 地址。如果你不明白,试试 Super User 或 Unix & Linux。

标签: git ssh gitlab ipv6 ipv4


【解决方案1】:

我遇到了同样的问题。这是我的网络。我尝试使用http://ipv6now.com.au/pingme.php ping gitlab,它成功了。当我从本地工作站发出 ping 命令时,它不起作用。我使用我在此处找到的说明http://sf-alpha.bjgang.org/wordpress/2012/08/linux-prefer-ipv4-over-ipv6-in-dual-stack-environment-and-prevent-problems-when-only-ipv4-exists/ 将我的工作站更改为更喜欢 ipv4。从本质上讲,我取消注释并将 /etc/gai.conf 中的行从 precedence ::ffff:0:0/96 10precedence ::ffff:0:0/96 100

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-04-17
    • 2014-04-08
    • 2017-06-01
    • 2013-10-13
    • 1970-01-01
    相关资源
    最近更新 更多