Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git and Bitbucket: unauthorized when pushing

I have created a repository in BitBucket and have cloned it using SSH. When attempting to push my changes to BitBucket, I receive the following error:

Unauthorized

fatal: Could not read from remote repository.

I have created an SSH key using ssh-keygen and have copied the resulting public key to BitBucket. I have downloaded SourceTree to see if a bit of tooling might help, but it has the same problem.

I've been trying to fix this for hours now and don't want to waste any more time on it. Surprising, I couldn't find anyone with a similar issue or even the same error messages when searching on Google.

Please help! I am running on Mac OS X and have tried deleting GitHub credentials from Keychain Access but this hasn't solved the issue. Does anyone know what I might be doing wrong?

Update

I have used exactly the same client-side configuration with GitHub, and ran into no issues, so I'm suspecting it's some configuration on BitBucket that I'm missing.

like image 926
serlingpa Avatar asked Jun 22 '19 20:06

serlingpa


People also ask

What is the push command in git?

The git push command is used to upload local repository content to a remote repository. Pushing is how you transfer commits from your local repository to a remote repo. It's the counterpart to git fetch , but whereas fetching imports commits to local branches, pushing exports commits to remote branches.


2 Answers

Just had the same issue and solved it.

My issue was that I added the generated public ssh key to the repo itself through the 'settings' of that repo.

The solution was to delete the ssh key from the repo itself. Click on your account. Add the ssh key through 'settings' of your account.

like image 165
Barry D. Avatar answered Sep 21 '22 13:09

Barry D.


Problem: Your public ssh key is added in REPO -> Settings -> Access keys

It only gives READ-Only Access as stated there

Use access keys to gain read-only access to this repository. Learn more about using SSH keys.

Solution: Add public ssh key in

Your profile -> bitbucket settings -> SSH-Keys

like image 35
Omer Aslam Avatar answered Sep 19 '22 13:09

Omer Aslam