0

I have setup key access to Github. Everything works well when I push from Git Bash command line. However I cannot use it from the command line. When I do a ssh -T git@github.com from command line, it says

Permission denied (publickey).

If I do a git push it says

Permission denied (publickey).
fatal: Could not read from remote repository.

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

I know that the keys are correct and the repository exists because it works fine from git bash. Any ideas?

Harlan Gray
  • 341
  • 6
  • 20
  • 1
    You either don't have an SSH agent running, or the agent doesn't know your SSH key. – Nils Werner Aug 29 '17 at 08:25
  • Possible duplicate of [Git - Permission denied (publickey)](https://stackoverflow.com/questions/2643502/git-permission-denied-publickey) – phd Aug 29 '17 at 15:57

2 Answers2

1

That could be one of two reasons: 1. you are not setup with a SSH key, which you have to get from git or the SSH key isn't linked to your account. I would recommend you try the HTTPS format from git instead of the SSH.

Help here: https://help.github.com/articles/connecting-to-github-with-ssh/

And there is even a github page for your question: https://help.github.com/articles/error-permission-denied-publickey/

matsbauer
  • 424
  • 3
  • 16
  • Thanks. I have setup the keys properly if not it will not work with Git Bash right? HTTPS is what I use usually, but I don't like to type in username and password always. I know credentials can be stored but I don't like to do that. I want to do it the recommended way from my windows command line. – Harlan Gray Aug 29 '17 at 08:48
-1

Check in your terminal, whether SSH agent is running or not, using following command :-

eval "$(ssh-agent -s)", if its not running, which seems to be the issue. then add your private keys to the ssh-agent using ssh-add ~/.ssh/id_rsa , where id_rsa is your private key.

After adding, your private keys to ssh-agent, verify its been added successfully or not using ssh-add -l command.

Amit
  • 30,756
  • 6
  • 57
  • 88