如何解决端口22连接超时问题

7
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.

我的防火墙已被禁用,但我仍然无法连接。我该怎么做?


不是答案,有没有启用详细ssh的方法: GIT_SSH_COMMAND="ssh -v" git clone example你甚至可以使用以下命令增加详细程度: GIT_SSH_COMMAND="ssh -vvv" git clone example - ErniBrown
你能展示一下你运行的一些命令吗?你正在推送/拉取的仓库是公共的吗?你输入的URL正确吗?如果你正在使用SSH,你的电脑是否有正确的密钥?请提供更多信息,以便我们能够帮助你! :) - Fabián Montero
你的/etc/hosts文件中是否有bitbucket.org的条目?如果有,请将其删除。 - Jim Redmond
你的电脑是否有使用SSH所需的正确密钥?@gaurav-singh - Fabián Montero
我找到了解决方法,只需在 /etc/hosts 中更改主机的 IP 地址即可。 - gaurav singh
显示剩余3条评论
4个回答

13

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

基本上,您可以使用443端口代替22端口。

  • 对于Github,答案如下:

To set this in your ssh config, edit the file at ~/.ssh/config, and add this section:

Host github.com
    Hostname ssh.github.com
    Port 443
  • BitBucket: Answers below confirmed you can still do this even though it was supposed to be discontinued on June 15, 2011:

     Host bitbucket.org
      Hostname  altssh.bitbucket.org
      Port  443
    
  • For Gitlab, the ssh config looks like this. Update the IdentityFile to match your local private key:

     Host gitlab.com
         Hostname altssh.gitlab.com
         User git
         Port 443
         PreferredAuthentications publickey
         IdentityFile ~/.ssh/gitlab
    

Sources:


0
对于 Bitbucket,这对我起作用:
Host bitbucket.org
 Hostname  altssh.bitbucket.org
 Port  443

0

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

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

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

-1

这对我有用。

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

我建议你阅读这个Github文档


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接