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 firstname.lastname@example.org
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 https://github.com/githubUsername/yourRepository.git
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 email@example.com:Github-username/reposiotory-name.git
Confirm that your public key ~/.ssh/id_rsa.pub is the one you have in your github account, to confirm this:
- Open ~/.ssh/id_rsa.pub , copy it's content
- Go to Github account > Settings > SSH and GPG Keys
- 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 "firstname.lastname@example.org"