Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When I clone a repo with git clone https://username@domain.com/directory 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

1 Answer 1

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
machine domain.com
login USERNAME
password SUPERSECRET
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 1.7.0.4, still asks for my password –  astropanic Mar 23 '11 at 11:00
    
You obviously need to adapt the created .netrc to your needs. See linux.die.net/man/5/netrc –  Holger Just Mar 23 '11 at 11:12
    
Sure :) is updated –  astropanic Mar 23 '11 at 12:34

Your Answer

 
discard

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.