如何解决端口22连接超时

时间:2018-08-28 12:18:19

标签: 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.

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

3 个答案:

答案 0 :(得分:0)

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

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

  • 对于 Github ,答案是:

      

    要在ssh配置中进行设置,请在〜/ .ssh / config中编辑文件,然后   添加此部分:

    Host github.com
        Hostname ssh.github.com
        Port 443
    
  • 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
    

来源:

答案 1 :(得分:0)

对于Bitbucket来说,这对我有用:

Host bitbucket.org
 Hostname  altssh.bitbucket.org
 Port  443

答案 2 :(得分:0)

我的回答有点晚,但我的配置文件适用于 GitHub 和 BitBucket

Host bitbucket.org
Hostname  altssh.bitbucket.org
Port  443

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