GitHub Error Message – Permission denied (publickey)

Question:

When I am trying to push changes into my GitHub repository, I am getting “Permission denied (publickey)” error:

Answer:

You are getting this error because GitHub isn’t able to authenticate you. So, either you aren’t set up with an SSH key, because you haven’t set one up on your machine, or your key isn’t associated with your GitHub account. Follow the below steps to set up your SSH key in GitHub.

  • Open your terminal and follow below commands
  • cd ~
  • sudo su
  • ssh-keygen
    • Enter file in which to save the key (/var/root/.ssh/id_rsa): $ id_rsa
    • Enter passphrase (empty for no passphrase): $ hit enter
    • Enter same passphrase again: $ hit enter
  • cd ~/.ssh
  • cat id_rsa.pub
  • copy display content. 
  • Open GitHub click your profile icon settings>SSH and GPC Keys
  • Click on the new ssh key button 
  • enter any title and key that you copied 
  • check now your issue is resolved

Leave a Reply