So, you have created your own SSH key pair and put the public key in your Bitbucket account at bitbucket.org
as described here:
https://support.atlassian.com/bitbucket-cloud/docs/set-up-an-ssh-key/
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.
There seems to be no obvious way to select a different SSH key that you might have already generated by yourself.
Workaround:
-
Backup your SSH keys and config files that are located in
~/.ssh/
-
Run SourceTree, go to
"SourceTree" -> "Preferences" -> "Accounts"
and select the account that you want to alter -
In the configuration dialog press the Option-Key. The
"Copy to Clipboard"
button will change to"Generate Key"
-
Press the
"Generate Key"
button -
Enter a passphrase and allow SourceTree to alter your SSH config
-
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 theconfig
file in the.ssh
folder:# --- Sourcetree Generated --- Host <bitbucket username>-Bitbucket HostName bitbucket.org User <bitbucket username> PreferredAuthentications publickey IdentityFile /Users/<macos-username>/.ssh/<bitbucket username>-Bitbucket UseKeychain yes AddKeysToAgent yes # ----------------------------
-
Change the
IdentityFile
entry to point to your SSH key file -
Restart SourceTree
-
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