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

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

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)

8 answers

1 accepted

6 votes
Answer accepted

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

Like mbr-sagor likes this

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! :-)

Like # people like this

This solved my problem too.

What is the use of the project ssh keys?

(Had my key added there, didn't allow me to push with it.)

This solved my problem too! 👍🏻

Mine too, thanks thumbs-up

is there any code can show me how to such problem?

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...

Like Nathan likes this

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. 

I saw the same thing when using the HTTP version of my repository. Switching to the SSH version solved this.

Screenshot 2019-01-28 at 11.14.42.png

Make sure you have access rights to the directory you are cloning into. 

My problem was the directory I was trying to clone into it did not have write access to on my local machine. Once I moved into a directory I had write access (in honestly I set the access rights to all all) then it worked for me. 

For clarity, in my circumstance I was trying to clone a git repository, after I had made sure that ssh-agent was running, my private key had been added to ssh-agent and successfully ran the tests as specified on this page: . This document was really helpful in the process too: .


I join the people, who have this problem. Strangely enough, sometimes it 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...

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?

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.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in DevOps

GitHub Script with GitHub Actions Automating Workflows

Hello folks, This is a series of articles where I explain GitHub Script with GitHub Actions and how you can automate publishing data on Atlassian & GitHub Platform based on the results of Workf...

187 views 1 2
Read article

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