如何解决端口 22 连接超时

gau*_*ngh 3 git ssh bitbucket

ssh: connect to host bitbucket.org port 22: Connection timed out
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

我的防火墙被禁用,我仍然连接超时。我该怎么办?

Emi*_* M. 6

看起来您对默认 SSH 端口有问题,可以通过使用其他端口来避免这些问题。这是一个常见的问题。

基本上,您可以使用端口 443 而不是 22。

  • 对于Github,答案是:

    要在 ssh 配置中进行设置,请编辑 ~/.ssh/config 中的文件,并添加以下部分:

    Host github.com
        Hostname ssh.github.com
        Port 443
    
    Run Code Online (Sandbox Code Playgroud)
  • BitBucket于 2011 年 6 月 15 日停止在端口 443 上使用 SSH,但我认为(请仔细检查)您可以告诉您的服务器管理员通过不同的端口设置 SSH 以防止超时(请参阅下面的来源链接)

  • 对于Gitlab,ssh 配置如下所示。更新 IdentityFile 以匹配您的本地私钥:

    Host gitlab.com
        Hostname altssh.gitlab.com
        User git
        Port 443
        PreferredAuthentications publickey
        IdentityFile ~/.ssh/gitlab
    
    Run Code Online (Sandbox Code Playgroud)

资料来源: