Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I clone a repo with git clone or when I push to it with git push origin master

Git asks me for a password, how I can automatically provide the password, like ssh keys for example ? So that it don't asks me for my password anymore ?

I need this for two reasons:

1)automation, hudson for example

2)I'm too lazy to provide it everytime by myself

Second question (it's related with the first one)

Why they asks sometimes twice for the password ?

share|improve this question

There is nothing like the SSH agent for http, so you have to provide the password in cleartext. You can save the credentials to ~/.netrc:

touch ~/.netrc
chmod 600 ~/.netrc
cat > ~/.netrc <<EOF

Note that the password is saved in clear text there. It is less secure than using encrypted SSH keys and ssh agent, but get's the job done. You are basically on the same security level as a default Subversion on most systems.

Note that newer versions of Git (> 1.7.0) make a better job of caching entered credentials, so you should only need to enter your password once there if you do not use the .netrc.

share|improve this answer
Doesn't work for me, git version is, still asks for my password – astropanic Mar 23 '11 at 11:00
You obviously need to adapt the created .netrc to your needs. See – Holger Just Mar 23 '11 at 11:12
Sure :) is updated – astropanic Mar 23 '11 at 12:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.