I have a following problem:
$ git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you ha
In my case I had this problem with GitLab because I was working with non-default SSH key pair paths. @NEO 's answer works perfectly:
ssh-add ~/.ssh/other_id_rsa
However, I had to do this everytime that I opened a new terminal.
To make this change permanent, you have to edit ~/.ssh/config
and add the following:
Host gitlab.company.com
RSAAuthentication yes
IdentityFile ~/.ssh/config/private-key-filename
For more detailed info check gitlab's documentation.
If you haven't already read it, you should look through the GitHub help page for this error:
Error: Permission denied (publickey)
Every time that I've had this problem, it was due to the last issue listed on that page: I didn't have the public key from my current workstation attached to my GitHub account. Of course, GitHub also provides instructions on how to attach your public key to your account.
tl;dr
Make sure your current public key is attached to your GitHub account.
I had the similar problem and my problem was solved by running the following command to add my key to the list of known keys:
ssh-add ~/.ssh/id_rsa
Hope it solves yours too. ;)