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.
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 ".
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.