1

I haven't changed the SSH key for the bitbucket for a while. All of sudden, it stopped working and I am seeing the following error from my source tree and command line.

Pushing to ssh://git@bitbucket.example.com:7998/project1/com.example.frontend.git
git@bitbucket.example.com: Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Pushing to ssh://git@bitbucket.example.com:7998/project1/com.example.frontend.git
git@bitbucket.example.com: Permission denied (publickey).
fatal: Could not read from remote repository.

I had to change the host/url for this post.

So I went inside the directory where this project is and ran this command, but got the same error.

git push
git@bitbucket.example.com: Permission denied (publickey).
fatal: Could not read from remote repository.

When I ran 'git config --list', I see the full list of config with my user name/company email/remote origin url.

I checked my public SSH key(which is in my account in BitBucket) with my local ssh key under ~/.ssh. It is identical.

Is there anything else that I can check or try?

Thanks.

user826323
  • 2,248
  • 6
  • 43
  • 70

1 Answers1

0

You need to test if your public key is registered to your hosted bitbucket account.

ssh -Tv -p 7998 -i ~/.ssh/mykey git@bitbucket.example.com

If it does work (meaning you get a "Shell access is disabled."), chekc your ~/.ssh/config content.

The OP mentions in the comments:

I regenerated the ssh key, and it started working...
I don't know why the old ssh key didn't work.

Sometimes, depending on OpenSSH version, it can be a format issue:
See "what is the correct format for private key in Credentials".

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • i am not getting "Shell access is disabled". – user826323 Jan 15 '20 at 15:44
  • @user826323 What are you getting? And do you have a ~/.ssh/config file? Also what is your OS (and OS version) as well as your Git version? – VonC Jan 15 '20 at 15:45
  • i regenerated the ssh key and it started working.. i don't know why the old ssh key didn't work.. – user826323 Jan 15 '20 at 18:53
  • @user826323 Thank you for this feedback. I have included your comment in the answer for more visibility. – VonC Jan 15 '20 at 22:10