Atlassian Bitbucket Cloud - ssh authentication - git pull works, git push fails
Asked Answered
V

2

6

1. Summarize the problem

I followed Bitbucket's instructions on setting up ssh.

I have a pub/priv key pair, and the pub key pasted into Bitbucket settings (Access Keys) for the project.

I have a build server on a GCE VM. git clone worked successfully, and git pull origin master works. I am using a passphrase.

However if I make a small change on a single file, git commit on the GCE VM, and do git push origin master, it fails with the following error message.

Enter passphrase for key '/home/proc/.ssh/id_rsa':
Unauthorized
fatal: Could not read from remote repository.

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

git remote -v shows

origin  [email protected]:<my-account>/<my-repo>.git (fetch)
origin  [email protected]:<my-account>/<my-repo>.git (push)

If git pull origin master works OK, then ssh is setup properly.

I added the following file: $HOME/.ssh/.config, with the contents below, but it did not help.

Host bitbucket.org
 IdentityFile ~/.ssh/id_rsa

my keyfile was generated with the following: ssh-keygen -t rsa -b 4096 -C "<comment>"

2. Provide background including what you've already tried

I've read every stack overflow article on Bitbucket authentication issues.

3. Show some code

git add <changed file>

git commit -m "made some updates"

git push origin master

4. Describe expected actual results including any error messages

I am trying to git push origin master to bitbucket.org.

Venn answered 13/9, 2019 at 14:36 Comment(6)
Your private SSH key (/home/proc/.ssh/id_rsa) requires an extra password - see https://mcmap.net/q/13497/-ssh-key-still-asking-for-password-and-passphraseDasyure
that solution does not work. it's called a pass phrase. I have a pass phrase set on my pub/priv key pair. The problem has nothing to do with a pass phrase. The response did not help. You yourself are not able to push to Bitbucket having your public key entered into Bitbucket settings (Access Keys), for the individual project. No one can.Venn
Sorry - figured Enter passphrase for key '/home/proc/.ssh/id_rsa': Unauthorized is probably a passphrase issue.Dasyure
When I enter my passphrase (correctly each time) - it gives an error: fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. It does not say incorrect passphrase, but accepts my passphrase. It's not a passphrase issue, my passphrase is 5 lowercase characters that I am entering correctly each and every time, I am able to pull with this 5 lower character passphrase, but not pull. If you have any ideas for a solution, please post. You could go try this first yourself, see the problem before responding.Venn
That is a different error - I would check the local/global git configs to see what user you are pushing as, and I would check permissions on the remote Bitbucket repository to see if that user indeed has write permissions. I would also verify that the public key uploaded to Bitbucket is the same as your local public key.Dasyure
I have the same problem and still no solution...Jernigan
C
1

Run ssh-agent /bin/sh then ssh-add ~/.ssh/id_rsa (replace id_rsa) with the name of your private key. Your push should work.

Cortege answered 17/8, 2022 at 15:55 Comment(0)
H
1

Assuming your BitBucket repository is public, anyone can pull from it without authentication. Authentication is only required when accessing a private repo or writing (pushing) to a public repo; so it's not surprising that pull and push behavior is different here.

Since you're confident your SSH passphrase is correct and your SSH keys are correctly installed on the server account, most likely it's a permission problem on the BitBucket Cloud repository itself. Check that your user has Write or Admin access in the Repository settings, AND that branch permissions/restrictions also allow you to push to the master branch you are trying to push. Both of these must be true or the push will fail with an authorization error similar to the one shown.

Heracliteanism answered 21/10, 2022 at 0:53 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.