How to provide authentication along with git command itself ?
Hello list,
During git push or fetch over http , I need to provide username and password every time, as protected by apache htpasswd file. How can I provide the same along with git command ? Or something so that It save the authentication info somewhere within .git
Thanks
Quoted 6 lines · J. Bakshi
Hello list,
During git push or fetch over http , I need to provide username and password every time, as protected by apache htpasswd file. How can I provide the same along with git command ? Or something so that It save the authentication info somewhere within .git
The http transport uses the ~/.netrc file to get its authentication data. man netrc will tell you about the syntax; for git, you need the 'machine', 'login' and 'password' fields.
Cheers,
cmn
Quoted 8 lines · On Thu, 14 Jul 2011 12:50:46 +0200 Carlos Martín Nieto <[email protected]> wrote:
Quoted 6 lines · J. Bakshi
Hello list,
During git push or fetch over http , I need to provide username and password every time, as protected by apache htpasswd file. How can I provide the same along with git command ? Or something so that It save the authentication info somewhere within .git
Quoted 9 lines
The http transport uses the ~/.netrc file to get its authentication data.
man netrcwill tell you about the syntax; for git, you need the 'machine', 'login' and 'password' fields.Cheers,
cmn
Thanks for the response. Can I use the same .netrc to store different authentication for different repo ? Is it somehow possible to store the information at the concerned .git of the repo ? I think this will be easier for multiple repos.
On Thu, 2011-07-14 at 16:29 +0530, J. Bakshi wrote:
[...]
Quoted 6 lines
Thanks for the response. Can I use the same .netrc to store different authentication for different repo ? Is it somehow possible to store the information at the concerned .git of the repo ? I think this will be easier for multiple repos.
I'm not sure, but netrc is not specific for any particular protocol. It assumes that your login and password are the same for several services on the same computer or set of computers.
It's often less hassle (and more efficient wrt. data transfer) to use SSH. With gitolite you can give people access to git repositories over SSH without giving them SSH access to the machine proper.
Cheers,
cmn
Quoted 5 lines · J. Bakshi
Hello list,
During git push or fetch over http , I need to provide username and password every time, as protected by apache htpasswd file. How can I provide the same along with git command ? Or something so that It save the authentication info somewhere within .git
Thanks
You probably want to create the client setup section of this:
http://kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt
Personally, I prefer to use an ssh hosted repository in such cases, then use an ssh-agent to cache an SSH private key.
jon.
Quoted 7 lines · On Thu, 14 Jul 2011 20:53:42 +1000 Jon Seymour <[email protected]> wrote:
Quoted 5 lines · J. Bakshi
Hello list,
During git push or fetch over http , I need to provide username and password every time, as protected by apache htpasswd file. How can I provide the same along with git command ? Or something so that It save the authentication info somewhere within .git
Thanks
Quoted 8 lines
You probably want to create the client setup section of this:
http://kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt
Personally, I prefer to use an ssh hosted repository in such cases, then use an ssh-agent to cache an SSH private key.
jon.
Well, I am using version 1.7, hence not DAV but using git-http-backend
Quoted 1 line · J. Bakshi
Well, I am using version 1.7, hence not DAV but using git-http-backend
Ah, I forgot to mention the docs for gitolite and http-backend[1].
As for your original question about how to set up or cache credentials, unfortunately I haven't tried it. Based on git-push(1), it looks like the usual
http://username:pass@domain/path/to/repo
syntax should work if you're passing the full URL on the command line or if it's okay to store the usernames and passwords in plaintext in .git/config.
If that's not okay, it also might be possible to hack up something evil with the GIT_ASKPASS variable. Some of the patches mentioned in the recent discussion about password prompts also might be interesting[2].
Regards,
Jonathan
[1] http://sitaramc.github.com/gitolite/doc/http-backend.html
[2] http://thread.gmane.org/gmane.comp.version-control.git/176522