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

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

Phillip Hobbs October 25, 2012

Getting

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
Colin Goudie
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
October 25, 2012

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.

Phillip Hobbs October 29, 2012

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

http://screencast.com/t/YX6f1X9gZ

I added the rsa one, does that make a difference? http://screencast.com/t/QtYeaxN9i9q

But I am getting the same error http://screencast.com/t/iZ17U2mn44mh

Here is what I am trying to do

http://screencast.com/t/gWGewHZA6

Like mbrsagor likes this
8 votes
Brennan Basinger January 22, 2018

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.

Normanbird May 9, 2018

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
jppresents June 23, 2019

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

gozpell June 29, 2019

This solved my problem too! 👍🏻

d-silva October 12, 2019

Mine too, thanks thumbs-up

Deleted user December 21, 2019

me too, cheers

We_Liang April 18, 2020

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

3 votes
swedishpotato September 20, 2018

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.

rowild September 20, 2018

Is your key created by SourceTree?

rowild September 20, 2018

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 bitbucket.org---(exchange whatever is her with what is written at HostName - must be equal, and most likely bitbucket.org)
HostName bitbucket.org
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 bitbucket.org, 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
rowild September 20, 2018

Here are some hopefully helpful read-ups:

https://apple.stackexchange.com/questions/48502/how-can-i-permanently-add-my-ssh-private-key-to-keychain-so-it-is-automatically

https://developer.apple.com/library/archive/technotes/tn2449/_index.html

 

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.

HTH

Normanbird September 20, 2018

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. 

1 vote
Johnathan Sewell January 28, 2019

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

0 votes
Judy Cook December 1, 2018

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: https://confluence.atlassian.com/bitbucket/troubleshoot-ssh-issues-271943403.html . This document was really helpful in the process too: https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html .

 

0 votes
rowild August 28, 2018

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:
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#adding-your-ssh-key-to-the-ssh-agent

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

0 votes
architchandra October 11, 2017

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

varunkumarj June 29, 2018

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

0 votes
Josip Matić December 2, 2016

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

Napoleon Arouldas September 12, 2017

Me too having the same problem.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events