Cannot push to git repository - permission denied

mc.suchecki picture mc.suchecki · Dec 2, 2012 · Viewed 61.1k times · Source

I have a following problem:

$ git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I have already checked the connection doing this:

$ ssh -vT [email protected]

and output looks good, I was correctly authenticated.

While checking further, I noticed that:

$ ssh-add -l
The agent has no identities.

I have tried to run ssh-agent, but nothing changed:

$ ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-A1mhFqvqncuO/agent.766; export SSH_AUTH_SOCK;
SSH_AGENT_PID=767; export SSH_AGENT_PID;
echo Agent pid 767;
$ ssh-add -l
Could not open a connection to your authentication agent.

I am using Arch Linux. Any help would be strong appreciated! Thanks in advance!

Github diagnostic help here.

Answer

NEO picture NEO · Aug 1, 2013

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. ;)