6

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!

7
  • RT*M. Commented Feb 3, 2015 at 12:25
  • Already done that. Tests work, but when I try to push or pull it still ask for username and password. Commented Feb 3, 2015 at 12:37
  • Are you sure ssh -T [email protected] gives you the right response? Commented Feb 3, 2015 at 15:46
  • Just tried again and receive the right response: Hi aloysia! You've successfully authenticated, but GitHub does not provide shell access. Commented Feb 3, 2015 at 16:04
  • Are you using the HTTPS URLs for your remotes? Commented Feb 3, 2015 at 21:58

1 Answer 1

9

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 [email protected]:user/repo.git

Sign up to request clarification or add additional context in comments.

2 Comments

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 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.
Thank you. The command you provided did not help me but reading that post did, so thanks. Here is the comment that helped me: stackoverflow.com/a/7773605/9935410

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.