6
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?

Fabián Montero
  • 1,613
  • 1
  • 16
  • 34
gaurav singh
  • 69
  • 1
  • 2
  • 5
  • Not an answer, anyway to enable verbose ssh: `GIT_SSH_COMMAND="ssh -v" git clone example` You can even increase verbosity with `GIT_SSH_COMMAND="ssh -vvv" git clone example` – ErniBrown Aug 28 '18 at 12:20
  • possible duplicate of https://stackoverflow.com/questions/15589682/ssh-connect-to-host-github-com-port-22-connection-timed-out – Nisarg Aug 28 '18 at 13:34
  • Can you show some of the commands you were running? Is the repo you are pushing/pulling from public? Did you enter the url correctly? If you are using SSH, does you computer have the right keys? Please provide more information so we can help! :) – Fabián Montero Aug 28 '18 at 14:55
  • Do you have an entry in your /etc/hosts file for bitbucket.org? If so, take it out. – Jim Redmond Aug 28 '18 at 17:47
  • ➜ amfrost_crm git:(master) git pull origin master 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. this is the request i am using @machetazo – gaurav singh Aug 29 '18 at 04:56
  • Does your computer have the right keys to use SSH? @gaurav-singh – Fabián Montero Aug 29 '18 at 16:01
  • i found the solution to this just change the ip address of the host in /etc/hosts – gaurav singh Sep 04 '18 at 10:01
  • Possible duplicate of [ssh connection timed out](https://stackoverflow.com/questions/45518078/ssh-connection-timed-out) – kenorb Jul 29 '19 at 22:03

4 Answers4

12

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:

Emilio
  • 2,526
  • 22
  • 26
0

For Bitbucket this worked for me:

Host bitbucket.org
 Hostname  altssh.bitbucket.org
 Port  443
cazuba
  • 329
  • 2
  • 5
0

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
Umar Ata
  • 4,170
  • 3
  • 23
  • 35
-1

This worked for me.

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

I suggest you reading this github docs

Francesco Taioli
  • 2,687
  • 1
  • 19
  • 34