how to resolve port 22 connection timeout

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

My firewalls are disabled and I still get connection time out. What should I do?

4 Answers

Looks like you have issues with the default SSH port and they could be avoided by using another port. This is a common issue.

Basically, you can use port 443 instead of 22.

  • For Github, the answer is:

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:

For Bitbucket this worked for me:

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

I am bit late to answer but my config file works for both GitHub and BitBucket

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

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

This worked for me.

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

I suggest you reading this github docs

Related