how to resolve port 22 connection timeout

18,335

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:

Share:
18,335
gaurav singh
Author by

gaurav singh

Updated on June 17, 2022

Comments

  • gaurav singh
    gaurav singh almost 2 years
    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?