Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to resolve port 22 connection timeout

Tags:

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.

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

like image 327
gaurav singh Avatar asked Dec 17 '22 21:12

gaurav singh


1 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:

  • 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

like image 170
Emilio Avatar answered Dec 27 '22 19:12

Emilio