Siteground has two basic control panels for managing their WordPress hosting platforms. Their bespoke new site tools system, and legacy accounts that are still using cPanel. For a couple of my clients sites hosted with the legacy cPanel hosting, I’ve recently lost the ability to push or pull via ssh to BitBucket, my git repository hosting service of choice. This is the type of message I’m getting lately, which had happened many months ago:

ssh: connect to host bitbucket.org port 22: No route to host
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

My first impulse was to check that I had my private/public ssh keys loaded up properly into BitBucket account, using good ol’ ssh -T [email protected] but that yielded the same error message of ssh: connect to host bitbucket.org port 22: No route to host

I reached out to Siteground and all they could tell me was that “they’ve never allowed SSH connections over port 22”. Which is weird, because it worked before. I know that the SSH port on SiteGround’s servers is 18765 instead of the general default port 22, since that’s what I have input into my ssh config file locally.

Luckily BitBucket has some backup options, which are mentioned at https://support.atlassian.com/bitbucket-cloud/docs/troubleshoot-ssh-issues/#TroubleshootSSHissues-Ifport22isblocked. Essentially to fix this, try fetching the repositories from Bitbucket Cloud using port 443 via SSH.

In your config file, normally my origin is set to soemthing like

[remote "origin"]
url = [email protected]:<account_name>/<repo_name>.git
fetch = +refs/heads/:refs/remotes/origin/

you can then change this to.

[remote "origin"]
url = ssh://[email protected]:443/<account_name>/<repo_name>.git
fetch = +refs/heads/:refs/remotes/bitbucket/

The command line commands for this would be:

git remote set-url origin ssh://[email protected]:443/<account_name>/<repo_name>.git

Hope that helps others out there.

I’ve also heard reports from a friend that it just took him barking up the right tree in Siteground until some sysadmin guy was like “well we can re-anable port 22 that we disabled”, and flipped the switch to make it good.

2 Comments

  1. Thank you for this excellent post!

    Like you, I have been using BitBucket with SiteGround without fail for several years until all of a sudden it stopped working.

    SiteGround clearly started blocking port 22 because my configuration hadn’t changed. To complicate matters, my setup supports multiple accounts so the config is slightly different.

    After some trial and error, the solution turned out to be straightforward. I simply changed the HostName to “altssh.bitbucket.org” and the Port to “443”. I didn’t have to change my git remote url or anything else.

    Here’s the updated .ssh/config:

    host bitbucket.org:
    HostName altssh.bitbucket.org
    User
    IdentityFile ~/.ssh/.private
    Port 443

    host bitbucket.org:
    HostName altssh.bitbucket.org
    User
    IdentityFile ~/.ssh/.private
    Port 443

    • Webmaster: it appears your comment filter mistook the placeholders for markup and stripped them out. Feel free to edit my comment so it properly displays. Thanks.

Leave a Reply

Your email address will not be published. Required fields are marked *

Post comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.