Fix: vscode git bitbucket Permission denied (publickey)

If you get this error while trying to push code on bitbucket in vscode:

Permission denied (publickey)

Try these steps:

Make sure your public key is on bitbucket settings:

  • Click on your Avatar icon
  • Go to Personal Settings
  • Under Security section go to SSH Keys
  • Using Putty gen – generate an SSH key pair. And add your public key in bitbucket. Like this:
  • Next open Pageant and add your private key ppk.
  • Also add your Bitbucket to your .ssh known_hosts file just to be safe:

On Windows path:

  • Open known_hosts file in notepad and get bitbucket current host’s public key using command:
ssh-keyscan -t rsa

The command output will be something like: ssh-rsa ...

Add the full line to known_hosts file

  • If you still are getting the above error, then it might be because vscode is not able to access some ssh file. Because of permission issues. Since everything is on your main OS C Drive. So making vscode run as Administrator might fix it:

Hopefully this post will help you fix the error 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *