So, you have created your own SSH key pair and put the public key in your Bitbucket account at as described here:

And now you want to use that key with SourceTree on macOS.

Here is how I managed to get this working:

In SourceTree if you enable SSH as an authentication protocol for accessing your bitbucket account the configuration dialog suggest that you use the id_rsa key that it apparently found in your .ssh folder.

SourceTree authentication configuration dialog

There seems to be no obvious way to select a different SSH key that you might have already generated by yourself.


  1. Backup your SSH keys and config files that are located in ~/.ssh/

  2. Run SourceTree, go to "SourceTree" -> "Preferences" -> "Accounts" and select the account that you want to alter

  3. In the configuration dialog press the Option-Key. The "Copy to Clipboard" button will change to "Generate Key"

  4. Press the "Generate Key" button

  5. Enter a passphrase and allow SourceTree to alter your SSH config

  6. SourceTree will generate a new key pair and store it in your .ssh folder under the name <bitbucket username>-Bitbucket. It also adds a new entry to the config file in the .ssh folder:

     # --- Sourcetree Generated ---
     Host <bitbucket username>-Bitbucket
         User <bitbucket username>
         PreferredAuthentications publickey
         IdentityFile /Users/<macos-username>/.ssh/<bitbucket username>-Bitbucket
         UseKeychain yes
         AddKeysToAgent yes
     # ----------------------------
  7. Change the IdentityFile entry to point to your SSH key file

  8. Restart SourceTree

  9. The account config dialog in SourceTree still suggests that SourceTree uses the key stored in the id_rsa file, but apparently it uses the one that is references in the .ssh/config file.

macOS: 11.6.1
SourceTree: 4.1.3