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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • 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

Permission denied (publickey)

Hi,

I'm using SourceTree v2.5.2 (111) to clone and push to Bitbucket.

When I trying the clone a project or to push, I'm getting the error:

Please make sure you have the correct access rights
and the repository exists.
Permission denied (publickey).
fatal: Could not read from remote repository.

I've tried to re-add the account, checked the ssh key, I'm still getting the error.

Any thought? Can anybody help me?

 

Thx

8 answers

1 accepted

84 votes
Answer accepted

Hi,

I was able to fix it!

I've tried to re-authorize SourceTree in the OAuth or regenerate the ssk key with `ssh-keygen`. Both didn't worked.

I did follow the documentation configure-multiple-ssh-identities-for-osx-linux

$ ssh -Tv git@bitbucket.org
OpenSSH_6.9p1, LibreSSL 2.1.8
...
Permission denied (publickey).

$ ssh-add -l 
2048 SHA256:... /Users/user/.ssh/id_rsa (RSA)

$ ssh-add ~/.ssh/user-Bitbucket
Enter passphrase for /Users/user/.ssh/user-Bitbucket: 
Identity added: /Users/user/.ssh/user-Bitbucket (/Users/user/.ssh/user-Bitbucket)

$ ssh-add -l 
2048 SHA256:... /Users/user/.ssh/id_rsa (RSA)
2048 SHA256:... /Users/user/.ssh/user-Bitbucket (RSA)

$ ssh -Tv git@bitbucket.org
OpenSSH_6.9p1, LibreSSL 2.1.8
...
logged in as user.

Then, I was able to push my commits. It's working!

The issue might have come after the reboot of the mac. The first one since I had install SourceTree v2.5.2 (110) for a better support of OAuth...

Thank You,  I had the same issue and this was helpful.  

Like # people like this

I had the same issue in the same scenario (after reboot I think) and this resolved it.  Thank you!

same issue here. The solution worked like a charm!
thanks

thnx my issue fix by above work.

thanks a lot!!!!

I had the same issue, and this solution saved me a time and energy :D thank you very much.

I had this problem and this solution worked.

I am on Sourcetree 2.7.3 (no recent updates).

Problem happened after an OSX update to High Sierra, osx 10.13.5 

Like richardv likes this

This solves my issue for ages!

This worked like a charm, thank you!

If I restart the computer I need to do this again, how to avoid this?

Like # people like this

@Arildo Junior you only need to do it once.

Worked for me but I only needed to do the first step, 

ssh -Tv git@bitbucket.org
Like # people like this

Solved my issue as well. 

Spot on! Thank you

Thank you ! In my case i had to start the agent with command:


eval `ssh-agent -s`


And then run the commands listed on your answer.

If you encountered this on 

ssh-add -l
The agent has no identities.

run this 

ssh-add -K ~/.ssh/id_rsa

to add the key into ssh agent. after this, run

ssh-add -l

fyi, i'm using macOS Mojave 

Like # people like this

This solved my issue.

Like olegvolleto likes this

Wow! You save me. Thanks a lot.

Great solution!

For people like me who do not understand what do you mean by "user-Bitbucket" in 

ssh-add ~/.ssh/user-Bitbucket 

I used id_rsa again and then I was able to do all actions like fetch, pull, or push.

 

NOTE: I was able to fetch/pull/push from XCODE or terminal but for some reason source tree was unable to do so.

Thanks for the great answer above. Worked :)

Thanks for info, this works for me

Sometimes it has to do with the ssh url in the config.

Change the url settings in the config file located under your .git folder inside your project.

i.e.

[remote "origin"]

url =git@Bitbucket.org:clicurt/appname.git

                  👇
url = https://username@Bitbucket.org/username/appname.git

This should get you connected to git using the ssh key pairs you set earlier on.

*Bold Italicized should be changed to you values accordingly.

Solved it for me in, despite everything in order above. There was one small note due to the fact that I was logging in to a "company" workspace that was not named for my account.


So where you have:

url = https://username@Bitbucket.org/username/appname.git

you might need to read it as this instead:

url = https://username@Bitbucket.org/workspace_name/appname.git

0 votes
jredmond Atlassian Team Jun 07, 2017

Which operating system are you using?

macOS v10.11.6

Same occurs for me. Has happened since the upgrade to 2.5.2. Switched back to https however that keeps asking for my password constantly. Atleast I can work though.

I've also switched to GitKraken which has no issues with the same repos and ssh. Might be worth switching everything over.

Thank you very much, the solution proposed in this post https://www.flynsarmy.com/2017/09/fix-permission-denied-publickey-git/ worked for me!

Like magedhamid likes this

Solved my issue, Thank You.

I have to push my repository to bitbucket but whenever i try to push it or clone my local repo with server it gives me error "permission denied(publickey)" i am using git tortoise on windows 8... any idea what i am doing wrong???

Thank You!

For me, i just had to delete the ssh keys in `~/.ssh` and regenerate new keys. Sourcetree was able to upload them into my github account and clone repositories again.

0 votes

Hello,

I followed all the steps above and I still get the following when I try to 'get fetch':

```

Permission denied (publickey).

fatal: Could not read from remote repository.

 

Please make sure you have the correct access rights

and the repository exists.

```

I am running on Google Cloud Compute Engine.

 

I generated a key, added it to the BitBucket, added the key to the chain etc. When I run `ssh -T git@bitbucket.org` I get the message `authenticated via a deploy key.`

 

I did try to git clone a repository on a different folder on the file system and it works fine. For this folder seems not working.

 

Thanks

Suggest an answer

Log in or Sign up to answer
TAGS
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,195 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