I got the error...
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
...when I was trying to make contact from a Git Bash prompt to Bitbucket after my laptop died from a bad Windows 10 update and was returned to factory settings. I had restored all my ssh files from a backup.
The cause of the error turned out to be a mismatch in my Windows account name after the computer rebuild. I learned that the public key file id_rsa.pub
ends with an easily readable string comprising my Windows account name followed by an @
sign and then the computer name.
When I originally set up my computer, I created my Windows account name including my middle initial but when my computer was reset to factory settings, our new DevOps guy created my account name without my middle initial.
To resolve the issue, I simply edited my public key file id_rsa.pub
and removed the middle initial in my name at the end. I had stuck with the same computer name so that was okay. I copied the file contents to the Windows clipboard. I then signed into Bitbucket, went to Bitbucket Settings under my avatar, and added a new public key where I pasted in the new contents.
Back at the Git Bash prompt, I confirmed that it now worked by entering the command...
ssh -T git@bitbucket.org
...and I got back a message that I was signed in.