5

Every time when I write

git pull origin master

or

git push origin master

or anything else in Git Bash I have to insert my username and password to login into GitHub.

I would like instead to automatically authenticate into GitHub using my Public and Private Keys.

I've already created the keys. They are into my local machine under ~/.ssh. I've attached the public key to my account as well. But I'm always asked for the username and password instead.

What do I still have to do to be able to login direct with the keys? Many thanks!

Aloysia de Argenteuil
  • 833
  • 2
  • 11
  • 27

1 Answers1

8

Based on this post https://stackoverflow.com/a/15034499 we learn that git won't ask for user and password only if the repository is configured to use ssh and NOT https.

We can change this using: git remote set-url origin git@github.com:user/repo.git

Community
  • 1
  • 1
Aloysia de Argenteuil
  • 833
  • 2
  • 11
  • 27
  • Thank you changing the remote url is what I needed, I had tried everything else from 5 other similar stackoverflow questions as well as the github docs. I had even worked out that it was the https urls that were giving me grief so I tried this https://help.github.com/articles/using-ssh-over-the-https-port/ but still I was asked for username and password each time despite having my username in git config. To recap what I needed was: - the username in config, - my key fingerprint at github, - the key added to my ssh agent and - the origin url needs to be the git@github one. – flurbius Jan 23 '18 at 21:21
  • Thank you. The command you provided did not help me but reading that post did, so thanks. Here is the comment that helped me: https://stackoverflow.com/a/7773605/9935410 – Jeff Austin Jan 29 '20 at 03:17