1

I created a repository today locally, on my USB, and then pushed it to Github. Before I restarted whenever I typed git push -u origin master it would ask for my credentials and then push my changes.

How would I set git to automatically enter them and just push it to the repo?

After I restarting, when I type git push -u origin master it returns an error

Permission denied (publickey).

fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.

What is causing this error and how do I fix it?

Jonathan
  • 6,507
  • 5
  • 37
  • 47
  • are u in *nix machine? – z atef Aug 01 '17 at 02:24
  • 2
    Not enough details? if you have keys already.. you may just want to do ss-add ~/.ssh/somekey (ssh-add -- adds private key identities to the authentication agent) – z atef Aug 01 '17 at 02:26
  • Possible duplicate of [Git keeps asking me for my ssh key passphrase](https://stackoverflow.com/questions/10032461/git-keeps-asking-me-for-my-ssh-key-passphrase) – phd Aug 01 '17 at 05:44

1 Answers1

2

If you want to automatically enter your credentials you can setup SSH Keys which are a way of secure, automatic authentication.

If you correctly do that, it should fix your Permission denied (publickey) error.

Skam
  • 7,298
  • 4
  • 22
  • 31
  • So after I posted I added an SSH key and did "git push -u origin (Github repo)" it asked for my credentials and logged me in, will I have to do this every time? – Robert Wagner Aug 01 '17 at 16:06
  • If you setup the SSH Key correctly, you shouldn't have to. – Skam Aug 01 '17 at 16:19
  • If it were me, I'd move the repository to my machine and make sure I wasn't doing anything to [disable gits credential helper for a single repository](https://stackoverflow.com/questions/13198143/how-do-i-disable-gits-credential-helper-for-a-single-repository/13203623#13203623) – Skam Aug 01 '17 at 16:21