8

I've been looking at a few different SO posts and other forums for an explanation of how to prevent git from constantly asking for my password whenever I interact with my remote repository, but all I understood was that I need to create ssh key.

RileyE
  • 10,874
  • 13
  • 63
  • 106
  • possible duplicate of [How do I store a password for my key so I can commit and pull from repository when using git on windows?](http://stackoverflow.com/questions/3625148/how-do-i-store-a-password-for-my-key-so-i-can-commit-and-pull-from-repository-wh) –  Jul 25 '13 at 18:22

2 Answers2

10

If you want to make your private key more secure, a passphrase is used to encrypt it. You can actually use ssh-agent to store your passphrase once for a terminal/console session, so you don't have to keep entering it all the time.

You'll need to use eval `ssh-agent -s` to start the agent, ssh-add to enter your passphrase for your private key, and then ssh-agent -k to kill the agent when you're done. It even comes with a timeout, ssh-add -t <timeout>, where <timeout> can be something like Xh for X hours, Xm for X minutes, and so on.

ssh-agent is available on msysGit and Cygwin. I'm not sure about its availability on other platforms like Unix/Linux/*nix systems and Apple OSX.

You can read more about ssh-agent usage from this Stack Overflow answer and this Stack Overflow answer, as well as googling around for instructions online.

Community
  • 1
  • 1
7

Create an SSH Key but don't enter a passphrase when it asks you to

https://help.github.com/articles/generating-ssh-keys

^ In step two of that article just press enter when it asks for a password

fm2munsh
  • 203
  • 1
  • 5
  • See! I am just an idiot. I couldn't even google something so simple. That is perfect and I'm on my way to a solution. Thank you! I'm using bitbucket, so here is a link for anyone in the same boat: https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git – RileyE Jul 25 '13 at 17:11
  • Is each public key (I'm assuming that's the `.pub`) inclusive? As in, do I need a unique `.pub` for each remote repository I have (3 if I have bitbucket, github and heroku repositories)? – RileyE Jul 25 '13 at 17:15
  • 1
    Not sure about bitbucket but with github, the ssh key is linked to your account, so any repository your account has access to, your ssh keys have access to – fm2munsh Jul 25 '13 at 17:21
  • 1
    @RileyE if you want to make your private key more secure, a passphrase is used to encrypt it. You can actually use `ssh-agent` to store your passphrase once for a terminal/console session, so you don't have to keep entering it all the time. You'll need to use `eval \`ssh-agent -s\`` to start the agent, `ssh-add` to enter your passphrase for your private key, and then `ssh-agent -k` to kill the agent when you're done. –  Jul 25 '13 at 18:20
  • @Cupcake Does the `ssh-agent` also have a timeout, or is it solely based on the terminal session and `ssh-agent -k`? But that is really good to know, since having a passphrase is much better, but it would be the same as having to put my HTTPS password in every time (before `ssh-agent`). – RileyE Jul 25 '13 at 18:23
  • @RileyE you can set a timeout like this: `ssh-add -t `, where `` can be something like `Xh` for X hours, `Xm` for X minutes, and so on. –  Jul 25 '13 at 18:24
  • @Cupcake Okay. That's quite helpful. So, would `ssh-add -t 8h30m` be a valid timeout request? – RileyE Jul 25 '13 at 18:27
  • @RileyE yes, that is valid. –  Jul 26 '13 at 05:39