Use SSH Key Exchange with BitBucket instead of HTTPS

By default, my BitBucket Git repository uses the HTTPS URL instead of the SSH. As a result, I get prompted for my password every time I push code to my BitBucket Git repository.

[code language=”bash”]
$ git push
Password for ‘https://<repo_owner>’:

You should see your BitBucket account username in place of <repo_owner> . If you want to avoid having to do this every time, you must configure BitBucket to have your SSH Key. Therefore, copy your SSH key (or generate one if you haven’t already) and add it your account settings in BitBucket (ie,<repo_owner>/ssh-keys/).

[code language=”bash”]
$ cat ~/.ssh/ | pbcopy

Now, you must configure your Git to use SSH instead of HTTPS. You can do this globally for all Git repos on your machine/account, by doing the following:

[code language=”bash”]
$ git config –global url.ssh://<repo_owner> https://<repo_owner>

You can confirm that this works by checking your global configuration file and look for the insteadOf:

[code language=”bash”]
$ cat ~/.gitconfig
[url "ssh://<repo_owner>"]
insteadOf = https://<repo_owner>

Now, you’ll be able to push code changes to BitBucket without being prompted for a password.



  1. Wow that was unusual. I just wrote an incredibly long comment but after I clicked submit my comment didn’t appear. Grrrr… well I’m not writing all that over again. Anyway, just wanted to say fantastic blog!

  2. As I website possessor I believe the subject material here is really great, thankyou for your efforts.

Leave a Reply

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