Git Bash : Permission denied (publickey) , cause and fix

Git Permission Denied

Getting Git permission denied errors with git on github ?

Permission denied (publickey). fatal: The remote end hung up unexpectedly

To get this running you need to confirm that you have a ssh key and it's corresponding in github.

Steps to fix and troubleshoot Git publickey error:

Confirm both name of repository and username:

git remote -v
ssh -T

This should show both your username and the github repository you created earlier, if username of repository is wrong you can use below command to reset it again:

git remote set-url origin

Now you can very one more time using git remote -v , you can also use ssh method instead of the https using:

git remote set-url origin

Confirm that your public key ~/.ssh/ is the one you have in your github account, to confirm this:

  1. Open ~/.ssh/ , copy it's content
  2. Go to Github account > Settings > SSH and GPG Keys
  3. Check if it's already there and if it's not there click on add new ssh key and paste it.

If you don't have ssh key in your Windows/Linux machine, run below command to create ssh key to use in Github:

ssh-keygen -t rsa -b 4096 -C ""


Subscribe to
for video tutorials updates

One thought on “Git Bash : Permission denied (publickey) , cause and fix

  1. Pingback: Git Quick Start - Learn How to Install GIT and More - dotsway

Comments are closed.