Solution: ‘Permission denied (publickey)’ for Windows

This post is mainly for Windows users who use git in the command line to push their projects on Bitbucket. I recently encountered the following error while trying to push a project into a new repository:

Permission denied (publickey).
fatal: Could not read from remote repository.

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

This error is caused because the URL you use to access your repository depends on the SSH protocol by default. The SSH authenticates you as a user and this error basically means the URL, for some reason, can’t be verified as authentic. One solution is to switch to the HTTPS URL format found here.


Did you follow the below steps in your Command Line after creating a new repository on Bitbucket?

$cd /path/to/my/repo
$git remote add origin
$git push -u origin --all # pushes up the repo and its refs for the first time
$git push -u origin --tags # pushes up any tags

Then do the following to switch to HTTPS authentication to fix the problem.
In your Terminal (Command Line), type the following:

$git rm remote origin  #removes the SSH origin URL
$git remote add origin
$git push -u origin --all

That should solve it!

And by the way, this error came up because I was trying to create a webpage using Bitbucket as a web host, which you can do here. Works just like Github Pages. Love this feature!

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s