1

After I changed password for my bitbucket account, I can't seem to push anything to the repository. I can pull, add, commit but not push.

I used to clone using https and whenever I push, it would say

Remote: unauthorized Fatal: Authentication failed for url. 

I search for this on google and stack overflow for 2 days, none of the solution worked.

So I decided to try SSH. I follow instruction to generate an SSH-Key and add it to bitbucket.
However as soon as I push it gave me:

repository access denied.
fatal: Could not read from remote repository.

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

pic here

Any idea on what to do?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Park Lee
  • 11
  • 1
  • 1
    Please show us the public key you've submitted to bitbucket (screenshot preferred), your local `id_rsa.pub` (not `id_rsa`!) from `~/.ssh`. These are both public keys. – mszymborski Aug 17 '18 at 20:49
  • When you added the SSH key to Bitbucket, did you also update the remote URL from HTTPS to SSH? – Jim Redmond Aug 20 '18 at 20:37
  • @JimRedmond Yes, I did change it to SSH. My remote is git@bitbucket.org:path/projectname. – Park Lee Aug 21 '18 at 13:16
  • @mszymborski link to the SSH public key https://postimg.cc/image/os4no7du3/ – Park Lee Aug 21 '18 at 13:18

2 Answers2

0

Regarding https, double-check if you have a credential helper which would have cached your credentials:

git config credential.helper

As explained in "How to sign out in Git Bash console in Windows?", this would remove the credentials:

git credential-manager delete https://bitbucket.org

Regarding ssh, double-check your key is proposed with:

set GIT_SSH_COMMAND="ssh -v"
git push
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
0

I'm going to take a wild guess: you're on macOS version 10.12 or later, right?

Apple changed the behavior of ssh-agent as of Sierra so that it no longer adds keys automatically. You can change this in one of several ways:

  • Add ssh-add -A to your .rc file (usually .bashrc, sometimes something else). This will add identities from your keychain to the ssh-agent. (You can add identities to the keychain with ssh-add -K.)
  • Update ~/.ssh/config to include something like this:

Host bitbucket.org IdentityFile /path/to/private/key AddKeysToAgent yes

(The SSH config file is a powerful tool, but different systems may have different options. Read man ssh_config to see which options you have available on a given system.)

Jim Redmond
  • 4,139
  • 1
  • 14
  • 18