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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,458,181
Community Members
 
Community Events
176
Community Groups

Can't push to my own repo (have SSH keys in personal settings)

Edited

Hi,

 

I created a new (not private) repository and cloned it to my system. When I want to push changes to the remote, I get this:

The requested repository either does not exist or you do not have access. If you believe this repository exists and you have access, make sure you're authenticated.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights

I saw a lot of posts about this on-line and they all seem to be about people using access tokens instead of having SSH keys. However, I have working SSH keys:

$ ssh -T git@bitbucket.org
authenticated via ssh key.

You can use git to connect to Bitbucket. Shell access is disabled

 

I also can push to other repositories for which I have write access however, with all the repos I create for myself I seem to have this issue. If I make the repo private, I can't even clone it.

Any ideas what I'm doing wrong?

 

1 answer

0 votes
Patrik S Atlassian Team Jan 10, 2023

Hello @Erik Trauschke ,

Thank you for reaching out to Atlassian Community!

The error you are receiving is most likely because the ssh key being used does not have the required permissions in the repository you are trying to push to.

The test with the ssh command you have used confirms the SSH key used is recognized by bitbucket for authentication, but when pushing to a repository, bitbucket also checks for authorization to confirm if that key has access to the content you are trying to read/write.

When you add an ssh key to your personal settings, this key will have the same access as your account, so your account needs to have write permissions to the repository you are pushing to.

Another thing that might be happening if you have multiple SSH keys in your local machine, is that the wrong key is being presented to git. In order to check what the key ssh is trying to use you can run the following command to include verbose logs : 

GIT_TRACE_PACKET=1 GIT_TRACE=1 GIT_SSH_COMMAND="ssh -vvv" git push

That will include ssh logs of the keys that were found and the order of precedence that ssh will attempt to use them.

By default in SSH, the first key that passes authentication will be used, but that does not necessarily mean that key has access to the repository in question. So make sure to identify if the key being used is the one you have added to the bitbucket account that has access to the repository. 

In case you indeed use multiple SSH keys, you might need to do some extra configurations for the correct SSH to be used for each user. You can refer to the following blog post with detailed instructions on how your local environment needs to be configured : 

Hope that helps! Let me know in case you have any questions.

Thank you, @Erik Trauschke !

Kind regards,

Patrik S

Hi Patrik,

 

Thanks for responding. These are some useful env variables to know about so I used them and it looks like everything is working as expected. I only have one key for this computer that is registered with bitbucket.

Regarding the access rights, I can log into bitbucket and edit files right there without any issues. I also tried to edit access rights directly, like adding myself as an admin, but it doesn't let me do that because I'm already the owner of the repo so should have explicit admin rights.

 

Erik

Like Patrik S likes this
Patrik S Atlassian Team Jan 11, 2023

Hey @Erik Trauschke ,

Could you confirm that the ssh key you identified is being used in the verbose logs, and was added to your bitbucket account under Personal settings as described in Provide Bitbucket Cloud with your public SSH key 

I ask this because if your key was added directly to a Project or Repository as an Access key, they will provide you with just read access to the repository, regardless of your account permissions. This would explain why you are not being able to push.

For the ssh key to have the same access as your account, you need to add them in your account's personal settings.

Thank you, @Erik Trauschke !

Hi Patrik,

 

I checked again and it is in fact picking up a key that I didn't realize I had in my setup. I will go and see how to change git to use a particular key and not the one found first.

 

Thanks for your help.

Erik

Like Patrik S likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS

Atlassian Community Events