In the SSH Key field of the SSH Client Configuration, I have inserted two keys separated by semicolons (like this: path/to/first/key; path/to/second/key;). All of my repos use either one or the other of these two keys. Both keys have passphrases on them. When I load SourceTree (for Windows), it prompts for the passphrase for each key, and after the passphrases are entered, the keys are loaded successfully. When I push to a remote Bitbucket repo, SourceTree only ever uses (i.e., offers to BitBucket) the first key in the SSH Key field. If I am unable to push, it is because the SSH key of the repo that is being pushed to is not the first one in the SSH Key field. If I switch the order of the two keys in the SSH Key field, I am again prompted to enter the passphrases for the keys when I close the Options dialog. With the order of the two keys switched, I am then able to push changes to the remote repo. Should there only ever be one key in the SSH key field? If so, then I don't think it should process all key entries in the field when the Options dialog is closed (that is, it shouldn't ask prompt for passphrases on all keys in the field). If > 1 key IS allowed in the SSH Key field, then is this a bug that Sourcetree only ever offers up the first key when it is attempting to connect to a remote repo?
Hi @Dan Swain
The semicolon-separated multi-key field in Sourcetree's SSH Client Configuration is misleading; it loads all keys into the agent but only actively presents the first one during auth. I would solve this by switching to OpenSSH instead of PuTTY:
Go to Tools → Options → SSH Client and change the SSH Client to OpenSSH and store your keys in the default location (~/.ssh/). Use an ~/.ssh/config file to map each host to the correct key, like:
Host bitbucket.org
IdentityFile ~/.ssh/key_one
IdentityFile ~/.ssh/key_two
OpenSSH will try each IdentityFile in order until one succeeds, which is exactly the behavior you want.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.