Permission denied (publickey). fatal: Could not read from remote repository.


Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

When trying to git clone from bitbucket account to my server (works fine locally on my mac)

6 answers

1 accepted

This widget could not be displayed.

Your server's private ssh key is most probably different to your local private key

You need to also tell Bitbucket about your keys on your server.

Thats why i suspected, but now I have added the ssh key from the cpanel account (I have a WHM and 3 accounts)

I added the rsa one, does that make a difference?

But I am getting the same error

Here is what I am trying to do

This widget could not be displayed.

Make sure you have added your key to your bitbucket profile settings and not your repository settings. The guide on how to generate a new ssh key does not explicitly make a distinction between the two. If you have added your key to the settings within your repository, then you won't have the correct access rights.

is was what I needed to see. Bitbuckets interface is not very intuitive. the 2 different settings with ssh keys threw me for a look. No idea there was a profile setting also. Come on Bitbucket! :-)

This widget could not be displayed.

I have the same problem. Even when I create key with kommand
ssh-keygen -t rsa -b 4096 -C "" and inspect that code, add them on my repository "Add key" still doesn't work.

Me too having the same problem.

This widget could not be displayed.

I'm facing the same problem. I have followed the steps in the guide by Bitbucket which tells how to set up a new SSH key and add it globally to Bitbucket. I did it via the Sourcetree GUI, but I still keep getting the message that Sourcetree could not read from the remote repository. I don't understand how to fix this.

Screen Shot 2017-10-12 at 12.19.17.jpg

Did u figure out how to solve this issue, using the sourcetree UI?

This widget could not be displayed.

I join the people, who have this problem. Strangely enough, The once works, then, after a while, it stops working and throws the error message Archit Chandra shows.

I also realized that, in `known_hosts`, the number of entries grows every time, when I update a repo via the Sourcecode app.

So I deleted all those entries. Being on a Mac, I also followed this advise:

Then it works again for a while.
If it stops, I repeat those steps...

This widget could not be displayed.

For me, this seems beyond complex.

Pulling down code from a code repository like Bitbucket to your local mac should be easy, but it isn't.

We've added 2-factor authentication to our Bitbucket account as now suggested by Bitbucket themselves, but copying the SSH and the HTTPS variants provided by Bitbucket themselves to clone the repository do not work.

Additionally, the various online guides on Bitbucket as to how to "solve" the various issues raised by their own commands are typically extremely terse and assume expert knowledge from the end user already. 

Is there a simple, step-by-step guide for a novice as to how on earth do a simple clone from a Bitbucket repository to your local mac, whilst at the same time fighting through the forest of impenetrable error messages it throws at you, such as, "Please make sure you have the correct access rights", or (my favourite), "To make a call, you need to use an app password." 

Frustrated - just want to get on with coding but can't. Any help gratefully received.

Is your key created by SourceTree?

If so, then change the name in the config file, because it seems that one is wrong:

1. Go to your .ssh folder in your User folder (on mac os 10.13 hit "CMD" + "." to make invisible files visible)

2. open the config file

3. look for sth like this:

# --- Sourcetree Generated ---
Host whatever is her with what is written at HostName - must be equal, and most likely
User ----
PreferredAuthentications publickey
IdentityFile /Users/rowild/.ssh/----
UseKeychain yes
AddKeysToAgent yes
# ----------------------------

4. Whatever is written at Hostname hass to be written to Host, too (most likely, if you have a free account)


This should work for one account. I've read that as soon as there are more accounts that want to access one repository, this is going to fail again. But the solution for that is actually posted somewhere on Apple, because it seems to be a problem with Apple's KeyChain (but I didn't dig too deep into that)

Otherwise I agree with you!

Bitbucket, make it easier. The simple fact that there are so many posts out there that concern this problem, should be indicator enough to let you know, there is something severely wrong with your service...

Here are some hopefully helpful read-ups:


Any always delete old, none.working key from your known_hosts and authorized_keys files, the mac keychain and as well as from your bitbucket repo.


Look for my response to the person who helped me above. that is the answer that solved it for me. 


Basically , follow the Bitbucket documentation to add your ssh key to the repository settings, and THEN ALSO, add the same SSH key to the PROFILE settings which ALSO has a second SHH key area.  That finally made the access denied stuff go away. :-) See full answer above for January 18, 2018, and my response. 

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Sep 17, 2018 in Teamwork

The tools we make for teams? We use them every day at Atlassian to get shit done (and it works).

I’m Jess, a Product Marketer for Jira Software Server and Data Center, and now a huge fan of our products. Read on for a 90 day, new-hire perspective on what it’s like to standardize on the Atlassian...

45 views 0 3
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you