Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Two different bitbucket accounts, macOS High Sierra - Permission denied (publickey). Edited


I've a private bitbucket account and one of my company.
SourceTree has automatically configured my ssh config file, where each entry (for each account) starts with "Host <username>-Bitbucket".
Since macOS Sierra, it isn't possible anymore to communicate with my bitbucket repos.
If I change the entry to "Host" it works for the first account, depends on which entry is listed first. For both entries, following settings are configured:

User <username>
PreferredAuthentications publickey
IdentityFile /Users/<user>/.ssh/<username>-Bitbucket
UseKeychain yes
AddKeysToAgent yes

Both passphrases are stored correctly in the keychain. I'm using SourceTree by the way, but it's the same in the terminal.

I would be so grateful to you, if you can help me - it's so annoying, the only workaround which i know, call "ssh-add -A" after booting.

Thanks guys!

1 answer

0 votes
Ana Retamal Atlassian Team Nov 08, 2017

Hi Andreas, if this issue is also happening to you in the terminal, then it's not caused by Sourcetree :)

To add both your Bitbucket accounts credentials separately, you can follow the instructions in this post Different SSH keys for different accounts on same Git hosting.

You can also find more info in our official documentation at Set up additional SSH keys.

You can also test the BitBucket server to see which account you are logging in with, to do that run:

ssh -v

And lastly if you need to cheack that the Keychain has the right kays, you can see all of them by running:

ssh-add -l

Let us know if this helps!

Best regards,


Hey Ana, thank you very much for your help :)

The ssh -v command really helps a lot to figure out such problems. (I've also tried <user>

I found out, that the ssh-agent always wants to use my default key (id_rsa) because of this output:
debug1: /Users/andreas/.ssh/config line 34: Applying options for *
This matches the line "Host *" of my ssh config.

I think anyway, SourceTree has some effect to this, here is my generated entry in the ssh config:

# --- SourceTree Generated ---
Host <user>-Bitbucket
    User <user>
    PreferredAuthentications publickey
    IdentityFile /Users/andreas/.ssh/<user>-Bitbucket
    UseKeychain yes
    AddKeysToAgent yes
# ----------------------------

So when does ssh choose exactly this key, located at the "IdentityFile" path.
The command mentioned above uses the key referenced "Host *", not the key of "Host <user>-Bitbucket".

In your link "Different SSH keys ..." I've seen the ssh-add command to add the new key - this works, but I don't want to do this after every restart. :/
So the problem is in the line "Host <user>-Bitbucket" I think, because the output should then be like "Applying options for <user>-Bitbucket".

Btw, my colleague has the same problem since a few days.

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Sourcetree

[dev team] Sourcetree for Windows 2019 Preview - Dark Theme

Hi folks, While the full post is over on our blog I'd like to share the dark theme we've got planned for 2019 here directly as well to keep the discussion going.  The ...

3,270 views 19 18
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you