Geoff Garbers

Husband. Programmer. Tinkerer.

Connecting to BitBucket on an HTTPS port

Mar 03, 2014

For any personal projects I develop, I make use of BitBucket for my version control. This is primarily because BitBucket offers private git repositories - which is really handy!

However, I find that when trying to connect to BitBucket through a normal SSH port (port 22), it can be unusually slow. I’m not sure whether this is just the connection, or whether my ISP throttles any non-HTTP(S) traffic. But in order to counteract this, and any firewalls your company or you might have in place, BitBucket provides an alternate hostname you can use to connect to your repositories.

Instead of using the normal bitbucket.org domain, you can use altssh.bitbucket.org as your repository’s origin. But don’t go and change your repositories just yet. There’s a simple trick to apply this for all your repositories: make a change in your ~/.ssh/config file. If this file doesn’t exist, it can be created. Simply place the following bit of text in there, and you’ll automatically start connecting to the alternate repository:

Host bitbucket.org
Hostname altssh.bitbucket.org
IdentityFile ~/.ssh/id_rsa.pub
Port 443

Now, any time you push, pull or clone from BitBucket using SSH, you’ll use port 443 on altssh.bitbucket.org. Considering this is normally a port for HTTPS traffic, the chances of it being blocked or throttled by your ISP or firewall would be much lower.