{"thread":{"id":"27813","subject":"How to provide authentication along with git command itself ?","startedAt":"2011-07-14T10:45:08Z","lastAt":"2011-07-14T20:02:44Z","messageCount":7,"participants":["J. Bakshi","Carlos Martín Nieto","Jon Seymour","Jonathan Nieder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"171315","messageId":"20110714161508.2378c155@shiva.selfip.org","threadId":"27813","inReplyTo":null,"subject":"How to provide authentication along with git command itself ?","fromName":"J. Bakshi","fromEmail":"joydeep@infoservices.in","sentAt":"2011-07-14T10:45:08Z","receivedAt":"2011-07-14T10:45:08Z","isPatch":false,"sender":{"key":"joydeep@infoservices.in","avatar":null},"body":"Hello list,\n\nDuring 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 \n\nThanks\n"},{"id":"171317","messageId":"1310640646.18730.10.camel@bee.lab.cmartin.tk","threadId":"27813","inReplyTo":"20110714161508.2378c155@shiva.selfip.org","subject":"Re: How to provide authentication along with git command itself ?","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-07-14T10:50:46Z","receivedAt":"2011-07-14T10:50:46Z","isPatch":false,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On Thu, 2011-07-14 at 16:15 +0530, J. Bakshi wrote:\n> Hello list,\n> \n> During git push or fetch over http , I need to provide username and\n> password every time, as protected by apache htpasswd file. How can I\n> provide the same along with git command ? Or something so that It save\n> the authentication info somewhere within .git \n\nThe http transport uses the ~/.netrc file to get its authentication\ndata.  `man netrc` will tell you about the syntax; for git, you need the\n'machine', 'login' and 'password' fields.\n\nCheers,\n   cmn\n"},{"id":"171318","messageId":"CAH3AnrqR=xMa6KYWBmybXdudo8C8FoeioCs2PgOVZezAE5BWiw@mail.gmail.com","threadId":"27813","inReplyTo":"20110714161508.2378c155@shiva.selfip.org","subject":"Re: How to provide authentication along with git command itself ?","fromName":"Jon Seymour","fromEmail":"jon.seymour@gmail.com","sentAt":"2011-07-14T10:53:42Z","receivedAt":"2011-07-14T10:53:42Z","isPatch":false,"sender":{"key":"jon.seymour@gmail.com","avatar":"https://avatars.githubusercontent.com/u/207131?v=4"},"body":"On Thu, Jul 14, 2011 at 8:45 PM, J. Bakshi <joydeep@infoservices.in> wrote:\n> Hello list,\n>\n> 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\n>\n> Thanks\n\nYou probably want to create the client setup section of this:\n\n    http://kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt\n\nPersonally, I prefer to use an ssh hosted repository in such cases,\nthen use an ssh-agent to cache an SSH private key.\n\njon.\n"},{"id":"171319","messageId":"20110714162953.36347b76@shiva.selfip.org","threadId":"27813","inReplyTo":"1310640646.18730.10.camel@bee.lab.cmartin.tk","subject":"Re: How to provide authentication along with git command itself ?","fromName":"J. Bakshi","fromEmail":"joydeep@infoservices.in","sentAt":"2011-07-14T10:59:53Z","receivedAt":"2011-07-14T10:59:53Z","isPatch":false,"sender":{"key":"joydeep@infoservices.in","avatar":null},"body":"On Thu, 14 Jul 2011 12:50:46 +0200\nCarlos Martín Nieto <cmn@elego.de> wrote:\n\n> On Thu, 2011-07-14 at 16:15 +0530, J. Bakshi wrote:\n> > Hello list,\n> > \n> > During git push or fetch over http , I need to provide username and\n> > password every time, as protected by apache htpasswd file. How can I\n> > provide the same along with git command ? Or something so that It save\n> > the authentication info somewhere within .git \n> \n> The http transport uses the ~/.netrc file to get its authentication\n> data.  `man netrc` will tell you about the syntax; for git, you need the\n> 'machine', 'login' and 'password' fields.\n> \n> Cheers,\n>    cmn\n> \n> \n> \n\nThanks 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.\n"},{"id":"171321","messageId":"20110714163149.63bad937@shiva.selfip.org","threadId":"27813","inReplyTo":"CAH3AnrqR=xMa6KYWBmybXdudo8C8FoeioCs2PgOVZezAE5BWiw@mail.gmail.com","subject":"Re: How to provide authentication along with git command itself ?","fromName":"J. Bakshi","fromEmail":"joydeep@infoservices.in","sentAt":"2011-07-14T11:01:49Z","receivedAt":"2011-07-14T11:01:49Z","isPatch":false,"sender":{"key":"joydeep@infoservices.in","avatar":null},"body":"On Thu, 14 Jul 2011 20:53:42 +1000\nJon Seymour <jon.seymour@gmail.com> wrote:\n\n> On Thu, Jul 14, 2011 at 8:45 PM, J. Bakshi <joydeep@infoservices.in> wrote:\n> > Hello list,\n> >\n> > 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\n> >\n> > Thanks\n> \n> You probably want to create the client setup section of this:\n> \n>     http://kernel.org/pub/software/scm/git/docs/howto/setup-git-server-over-http.txt\n> \n> Personally, I prefer to use an ssh hosted repository in such cases,\n> then use an ssh-agent to cache an SSH private key.\n> \n> jon.\n\nWell, I am using version 1.7, hence not DAV but using git-http-backend \n"},{"id":"171322","messageId":"1310641975.6041.3.camel@centaur.lab.cmartin.tk","threadId":"27813","inReplyTo":"20110714162953.36347b76@shiva.selfip.org","subject":"Re: How to provide authentication along with git command itself ?","fromName":"Carlos Martín Nieto","fromEmail":"cmn@elego.de","sentAt":"2011-07-14T11:12:55Z","receivedAt":"2011-07-14T11:12:55Z","isPatch":false,"sender":{"key":"cmn@elego.de","avatar":"https://avatars.githubusercontent.com/u/335443?v=4"},"body":"On Thu, 2011-07-14 at 16:29 +0530, J. Bakshi wrote:\n[...]\n> \n> Thanks for the response. Can I use the same .netrc to store different\n> authentication for different repo ? Is it somehow possible to store\n> the information at the concerned .git of the repo ? I think this will\n> be easier for multiple repos.\n> \n\nI'm not sure, but netrc is not specific for any particular protocol. It\nassumes that your login and password are the same for several services\non the same computer or set of computers.\n\nIt's often less hassle (and more efficient wrt. data transfer) to use\nSSH. With gitolite you can give people access to git repositories over\nSSH without giving them SSH access to the machine proper.\n\nCheers,\n   cmn\n"},{"id":"171375","messageId":"20110714200244.GA14687@elie","threadId":"27813","inReplyTo":"20110714163149.63bad937@shiva.selfip.org","subject":"Re: How to provide authentication along with git command itself ?","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2011-07-14T20:02:44Z","receivedAt":"2011-07-14T20:02:44Z","isPatch":false,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"J. Bakshi wrote:\n\n> Well, I am using version 1.7, hence not DAV but using git-http-backend \n\nAh, I forgot to mention the docs for gitolite and http-backend[1].\n\nAs for your original question about how to set up or cache credentials,\nunfortunately I haven't tried it.  Based on git-push(1), it looks like\nthe usual\n\n\thttp://username:pass@domain/path/to/repo\n\nsyntax should work if you're passing the full URL on the command line\nor if it's okay to store the usernames and passwords in plaintext in\n.git/config.\n\nIf that's not okay, it also might be possible to hack up something\nevil with the GIT_ASKPASS variable.  Some of the patches mentioned in\nthe recent discussion about password prompts also might be\ninteresting[2].\n\nRegards,\nJonathan\n\n[1] http://sitaramc.github.com/gitolite/doc/http-backend.html\n[2] http://thread.gmane.org/gmane.comp.version-control.git/176522\n"}]}