Skip to content

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

An answer to this question on Stack Overflow.

Question

I have followed these instructions below to upload a project.

Global setup:

 Download and install Git
  git config --global user.name "Your Name"
  git config --global user.email tirenga@gmail.com
  Add your public key
        
Next steps:
  mkdir tirengarfio
  cd tirengarfio
  git init
  touch README
  git add README
  git commit -m 'first commit'
  git remote add origin git@github.com:tirenga/tirenga.git
  git push origin master
  

But I get this error:

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

Answer

You need to set up SSH keys.

This GitHub page explains how to generate keys.

If you have an existing key, you copy $HOME/.ssh/id_rsa.pub and paste it into the GitHub SSH settings page.