8

I'm new to using git. Each time I want to push my file to github, it always shows me notification to enter my passphrase. Ex: password for 'https://username@bitbucket.org'

I want my git remember the passphrase for me. How should I possibly do that on windows 7? I've already read the help page here https://help.github.com/articles/set-up-git

michas
  • 25,361
  • 15
  • 76
  • 121
Ahmed el-Gendy
  • 436
  • 6
  • 13
  • 1
    Just use an ssh-agent as pointed out in [this answer](http://stackoverflow.com/questions/4083079/how-to-run-git-ssh-authentication-agent) – Nevik Rehnel Dec 23 '12 at 11:44
  • putty comes packaged with an agent, use that one. – Flavius Dec 23 '12 at 12:00
  • 3
    Why do people vote to close such questions as off-topic, if the FAQ clearly states: `software tools commonly used by programmers`: http://stackoverflow.com/faq. SO has become so infected, poisonous people! http://www.youtube.com/watch?v=Q52kFL8zVoM – Flavius Dec 23 '12 at 12:12
  • The OS is a tool commonly used by programmers. Should questions such as "I can't find my backups" be allowed? How about changing colour schemes in the command line? How about not being able to install a webserver for testing your program on? All related to programming, yes. But I argue that they are not _programming_ questions. There are other StackExchange sites for questions like this. All IMHO - which is why it takes a vote to close / transfer questions. – Abizern Dec 23 '12 at 12:36
  • 1
    I'd say this should be moved to superuser.com rather than simply be closed. – Schwern Dec 24 '12 at 02:28
  • @Abizern If you really mean what you wrote in your comment that you should have prposed the move and not the close. Please admins WAKE UP! Stop beeing so negative and nonvelcoming, before you totally spoil helpful atmosphere on SO. – gorn Nov 28 '14 at 01:18

2 Answers2

11

If you're following the instructions on Github, note this line.

Good to know: The credential helper only works when you clone an HTTPS repo URL. If you use the SSH repo URL instead, SSH keys are used for authentication.

You're using ssh, so the git credential helper isn't going to work. You have a few options.

  • Set up an ssh-agent to store your ssh key passwords.

The ssh issue isn't specific to git. You can set up an ssh-agent so you only have to enter an ssh key password once. It will be remembered, safely stored in memory, until you log out. Github has a tutorial about setting up an ssh-agent.

No matter which option you pick, I would highly recommend you take the time to set up an ssh-agent. Ssh is so useful and so widespread you're going to run into this problem again.

  • Switch to using https instead of ssh.

Instead of cloning from git@github.com:username/my-repo.git you can clone from https://github.com/username/my-repo.git. It's the http button on your project page. Then the git credential helper described in the github docs will work. You'll probably have to install it first, or use their Github app. This is all described in the Password Caching section of the Github on Windows setup guide.

  • Use their Github app.

The guide mentions they have a Github app now and it can probably take care of this for you. However this is only a stop gap as other git servers won't have such a thing.

Schwern
  • 153,029
  • 25
  • 195
  • 336
  • but, I use https:// and i don't use Github app ,please i need your help. – Ahmed el-Gendy Dec 23 '12 at 12:12
  • @Ahmedel-Gendy Your post originally said the message was "Ex: Enter passphrase for key '/c/Users/.ssh/id_rsa'" which is ssh. Now you've changed it to https. Anyhow, as in my answer and in the [Github guide](https://help.github.com/articles/set-up-git#platform-windows), use the Github app which will set up the git credentials manager for you. See the "password caching" section. – Schwern Dec 24 '12 at 02:27
  • 1
    i use this steps and to use ssf thanks alot @Schwern – Ahmed el-Gendy Dec 25 '12 at 14:13
2

github allows two different methods to access your repository: https and ssh.

In the first version of your question, you configured git to access github via ssh. Therefore git calls ssh which tries to read your keys and asks you for the passphrase of the ssh-key.

When you create your ssh key, you may protect it by a passphrase or decide not to do so.

In case you decide for a passphrase then you either have to type the passphrase each time you want to use your key (i.e. push, fetch, etc.) or you can use ssh-agent. In the last case you only have to type the passphrase once when adding you key to the agent. Afterwards the agent will do all authorization for you.

On Windows you can use the PuTTY tools to manage your keys: http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html

You can use puttygen to generate a new key or change an existing one. (for example to remove the passphrase)

You can use pagent as a ssh agent. After starting it will reside in the notification area. Click on the icon to add your key.

Once your agent knows about the key, you should no longer be asked for your ssh passphrase.

michas
  • 25,361
  • 15
  • 76
  • 121