git - 如何解决端口 22 连接超时

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

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

最佳答案

看起来您对默认 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 于 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
    

  • 资料来源:
  • https://about.gitlab.com/2016/02/18/gitlab-dot-com-now-supports-an-alternate-git-plus-ssh-port/
  • https://help.github.com/en/articles/using-ssh-over-the-https-port
  • https://confluence.atlassian.com/bitbucketserver/enabling-ssh-access-to-git-repositories-in-bitbucket-server-776640358.html
  • 关于git - 如何解决端口 22 连接超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52057705/

    相关文章:

    git checkout : what does this weird output mean?

    linux - 找到 : missing argument to -exec with ssh

    docker - SSH key 不断从 Google Compute Engine VM 中删除

    linux - 到远程服务器的 SSH 隧道故障

    bitbucket - 如何通过链接共享私有(private) Bitbucket 存储库?

    bitbucket - Sourcetree 使用两因素身份验证添加 bitbucket

    git svn clone 失败并显示 "Failed to strip path"

    linux - RHEL 7.4 中的 git 升级

    git 状态(没有提交,工作目录干净),但是已提交更改

    jenkins - 在 Jenkins 作业中访问 BitBucket webhook 的有效负载