Bitbucket Using SSH Keys

The announcement that GitHub would train its AI on your code unless you opted out prompted two actions on my part:

  1. Immediately change my Github settings to opt-out.
  2. Identify a replacement to host my repositories.

After an admittedly shallow evaluation, I chose Bitbucket for migrating from GitHub: in fact, BitBucket makes a stupidly-easy to import a repository from anywhere and quickly be up-and-running.

My only difficulty was uploading an SSH key for cloning repos and pushing changes. Once I got it working – with help from web searches and AI – I wanted to share so others don’t waste time as I have today!

0. Create SSH Key

While the existing Github key could be uploaded to BitBucket, I prefer single-tool keys. Use ssh-keygen to create the key for Bitbucket’s use.

1. Navigate to Personal Bitbucket settings

Immediately adjacent to your avatar is the settings icon. Click first on the icon to show the drop-down menu; from the Personal Settings submenu select Personal Bitbucket settings.

2. Navigate to Your SSH Keys

From the lefthand navigation, expand the Security submenu and select SSH Keys.

3. Add SSH Key

Assuming you are creating your initial SSH keys, you should see the explanatory message There are no SSH keys associated with this account. Click on the Add key button.

4. Create SSH Key

Copy the public key from ~/.ssh – in my case, from ~/.ssh/mybitbucket_ed25519.pub to the SSH Public Key field. The Name is strictly to help you manage keys. Click on Add key when the fields are correctly populated.

Note: for security reasons I had redacted my actual key. Normally a series of alphanumeric characters follow the ssh-ed25519 header.

5. Review

The newly created key should now be listed.

NOTE: The Fingerprint field has been redacted for security reasons.

6. Create SSH Config

Keys created using unique names (i.e., mybitbucket) must be registered in ~/.ssh/config.

7. Test

The command ssh -T git@bitbucket.org tests your configuration; any message other than authenticated via ssh key indicates problems.

Disclaimer

I don’t have a Windows box to, nor do I want to, so I can’t help you there. I seems that Windows has multiple techniques for using SSH keys – i.e., putty, git shell, etc. – so your tools and development processes are going to drive how you accomplish what I’ve described above. I can’t help you, you’re on your own!