Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Permission denied (publickey)

Nelkur February 16, 2019
Permission denied (publickey).
fatal: Could not read from remote repository.

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

So I'm trying to clone my repo on bitbucket into a folder inside my centos 7 VPS and I keep getting that error.

I will note that I haven't added any keys to the repository. Do I have to? I had previously generated a ssh key in my local computer which I then added to another one of my repositories (not the one I'm cloning).

How do I fix this?

1 answer

1 accepted

1 vote
Answer accepted
Marty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 17, 2019

Hi Nelson,

yes I would try adding your generated ssh key to the repo you're trying to clone.

I hope that helps!

Nelkur February 19, 2019

Thank you for that.
I generated a ssh key in my server and added the public key to the repository I was trying to clone and it worked perfectly! I couldn't add the key that already existed on my local computer because bitbucket complained that the key was being used by another repository, which makes sense. Is there a way to have one key for all my repositories instead of having to generate new keys? I might be missing something.


After adding the public key from my server to the repository, I now can't `git push origin master` from my local machine to that repo, which I could do before. Am I supposed to copy the server's private key onto my local machine or what? If so, where would I store the file and what else would I have to do? If not, what then?
Is there a better way to do all this?

Like Marty likes this
Marty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 19, 2019

Hi Nelson,

typically you setup your own private/public key pair, keep the private key on your machine and upload your public key to bitbucket.

See here for the Cloud docs: https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html

I hope that helps!

Nelkur February 19, 2019

Hi.
I already have a ssh key pair on my local machine but I've added that public key to a repository on bitbucket. Trying to add the same public key to yet another repository refused to work.

Regarding the `git push origin master` issue, that's because I generated a ssh key pair on my server and added that public key to the repository - the server's public key that is. Trying to push from my local computer is what raises the error.

What can I do about that?

Marty
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 19, 2019

Hi Nelson,

you can have more than one key pair on your local machine.

Have you tried generating another keypair and adding this to the second repository?

As for the issue with pushing, you will only be able to push to the repo from the server because the private key is on the server, not on your local machine.

I hope that helps!

Like Nelkur likes this

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events