3

I am new to gitolite. I am trying to do a very simple test with gitolite. I have setup my repository called "test_repo". Please note that I have not modified anything else otherthan what I have stated below. I can see this repo in gitweb. This is the repo configuration

repo test_repo
    RW+     =   @all

Now I want to clone this repo. I have ldap access to server. By my understanding of @all, it should allow me to do this.

when I issue

git clone git@myserver:repositories/test_repo.git 
#I know this is wrong. But I just wanted to test as the above did not work

or

git clone git@myserver:test_repo.git

its asking for password. I have followed this guide http://sharadchhetri.com/2013/05/31/how-to-create-own-git-server-with-gitolite-and-gitweb-in-ubuntu/, which does not set a password for git user

When I issue

git clone myname@myserver:test_repo.git

I am getting the following error

fatal: 'test_repo.git' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

I also tired to clone the default repo "test_repo.git". But I am getting the same error.

I also tired this

git clone myname@myserver:/home/git/repositories/testing.git

then cloning is working. But when I do git push -u origin master some modified files I am getting

error: insufficient permission for adding an object to repository database ./objects
fatal: failed to write object
error: unpack failed: unpack-objects abnormal exit
! [remote rejected] master -> master (n/a (unpacker error))

Note: I have not added any user in conf file

Any help is appreciated.

knightrider
  • 2,063
  • 1
  • 16
  • 29

2 Answers2

2
 git clone myname@myserver:/home/git/repositories/testing.git
  • that completely bypass gitolite, which isn't called
  • use the wrong account 'myname' which has no right to read the git account folders.

What should work is:

 git clone git@myserver:test_repo.git
 or
 git clone git@myserver/test_repo.git

You shouldn't specify the 'repositories' folder (gitolite knows where the repo is supposed to be)

That supposes that ssh -Tvvv git@myserver works (ie do not ask password).
Make that ssh work first, and then try again the git clone.


As I say in the comment, LDAP and ssh are both authentication mechanism, so you can use one or the other, not both:

If the ssh works, but the clone doesn't work, then you need to have a look in the gitolite logs at ~git/.gitolite/logs

I could not find anything useful in the log. Moreover I did a tail -f of the log file. Its not even updated when I try to clone.

That means the issue is on the ssh level, not calling properly gitolite: that is in ~git/.ssh/authorized_keys, and happens if you add an ssh key manually directly in it, instead of adding through the keys folder of the gitolite-admin repo and pushing back that repo to the gitolite server (which triggers the update of said ~git/.ssh/authorized_keys file).

I think that could be the reason. I have no idea what just happened. I can even clone gitolite-admin, in admin server (this was working earlier).
I will re install every thing (because I think I messed up a lot with config files by now).

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • ssh -Tvvv git@myserver asks for password – knightrider Aug 01 '13 at 11:48
  • please note that the client which I am trying to login is not the admin system. Also I have not added the keys of this system. – knightrider Aug 01 '13 at 11:54
  • I dont want to add the ssh because it means that every have to do so. I would like ldap to do authentication – knightrider Aug 01 '13 at 12:02
  • For testing I added the keys.so `ssh git@myserver` is working. But when I use : then it shows the same error as before. When I use \ it shows `fatal repository does not exist` – knightrider Aug 01 '13 at 12:05
  • @knightrider You can have apache + LDAP (+ gitolite) as I illustrates in http://stackoverflow.com/a/17985744/6309, or ssh + gitolite. But not ssh + LDAP + gitolite. ssh authenticates. Or LDAP authenticates. Not both. So when cloning a repo with an ssh url, you always use '`git`', not '`user`'. – VonC Aug 01 '13 at 12:41
  • Thanks for the link. I think we can ignore LDAP now as all the above assumed ssh. I still cant figure out why the cloning is not working – knightrider Aug 01 '13 at 12:45
  • @knightrider If the ssh works, but the clone doesn't work, then you need to have a look in the gitolite logs at `~git/.gitolite/logs` – VonC Aug 01 '13 at 14:34
  • I could not find anything useful in the log. Moreover I did a `tail -f` of the log file. Its not even updated when I try to clone – knightrider Aug 01 '13 at 14:43
  • @knightrider good information! That means the issue is on the ssh level, not calling properly gitolite: that is in `~git/.ssh/authorized_keys`, and happens if you add an ssh key manually directly in it, instead of adding through the keys folder of the `gitolite-admin` repo and pushing back that repo to the gitolite server (which triggers the update of said `~git/.ssh/authorized_keys` file). So, what does your `~git/.ssh/authorized_keys` looks like? – VonC Aug 01 '13 at 14:46
  • I think that could be the reason. I have no idea what just happened. I can even clone gitolite-admin, in admin server (this was working earlier). I will re install every thing (because I think I messed up a lot with config files by now). I will try the ldap method now as I redoing everything. Please keep a watch on this thread in case I require any more info – knightrider Aug 01 '13 at 14:59
  • @knightrider I [always keep a watch every single day](http://meta.stackexchange.com/q/122976/6309) ;) I have edited the answer to reflect the findings so far. – VonC Aug 01 '13 at 15:23
  • finally after re installation it is working. I added user using gittolite and things are good. So what is not working is gitweb using ldap and git using gitolite and ssh – knightrider Aug 02 '13 at 10:00
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/34681/discussion-between-knightrider-and-vonc) – knightrider Aug 02 '13 at 10:00
  • @knightrider unfortunately, I cannot access the chat while at work. – VonC Aug 02 '13 at 10:18
  • I dont know much about apache configuration. But I have an important question. I want to give unrestricted access to all users preferably using gitolite. Is this possible. But for now, when ever I want to give a user access to git (using ssh), I have to add his keyfile using gitolite. By using ldap, can this be eliminated (In future may be this is not the case). – knightrider Aug 02 '13 at 10:21
  • @knightrider yes, ldap would allow you to not worry about ssh key, but that supposes an Apache setup. That is what I describe in http://stackoverflow.com/a/17985744/6309 – VonC Aug 02 '13 at 10:28
  • I am trying not to use the certificate. Also I cannot locate the gitolite-shell. In the bin directory I can only find gitolite – knightrider Aug 02 '13 at 12:09
  • @knightrider certificate is for https access. Simply remove all SSL lines and you won't have to use a certificate. In gitolite v3, I do have `gitolite-shell` in addition of `gitolite` in my `/bin` folder. – VonC Aug 02 '13 at 12:11
  • I am using version V3.5. I searched in installdir bin, /usr/bin, /usr/sbin, /bin and /sbin. its not there – knightrider Aug 02 '13 at 12:13
  • I found that in installdir/src/. I will create a link in bin – knightrider Aug 02 '13 at 12:14
  • @knightrider not sure if that will work. It seems like a spotty buggy installation to me. Here is my gitolite installation script: https://github.com/VonC/compileEverything/blob/master/gitolite/install_or_update_gitolite.sh#L27-L53. I use a `"${github}/install" -to "${gtl}/bin" ; GITOLITE_HTTP_HOME= gitolite setup -pk "${H}/.ssh/gitoliteadm.pub"` to install gitolite in `${gtl}/bin` (which is in my `$PATH`) – VonC Aug 02 '13 at 12:18
  • gitolite was in bin, but not gitolite-shell. Also gitolite was actually a link to source. Finally I have configured my htdocs http://pastebin.com/4bVFCCCx . Now when I try `git clone http://:7777/hgit/testing.git` its showing `fatal ***service=git-upload-pack not found: did you run git update-server-info on the server?` – knightrider Aug 02 '13 at 12:40
  • @knightrider do you see that error message *after* having passed the LDAP authentication dialog? Or before? And beware that `AuthBasicProvider` is supposed to reference an LDAP *alias* define before-hand. – VonC Aug 02 '13 at 12:47
  • It did not ask for authentication. Is the url correct? I am using `AuthBasicProvide ldap` and an `AuthLDAPURL`. Its shown in pastebin.com/4bVFCCCx. These two lines were copy pasted from gitweb conf file which works – knightrider Aug 02 '13 at 12:52
  • @knightrider the url is correct. "from gitweb conf file which works" you mean mine? Do you see anything relevant in the `githttp_..._log` files? – VonC Aug 02 '13 at 12:54
  • No I mean my gitweb conf file. I found the problem. It was access issues with the link I create. I fixed it. Now its asking for username and password. After I enter that I have more errors (when will this end). I have pasted the output of errorlog in http://pastebin.com/FEett4mu – knightrider Aug 02 '13 at 13:02
  • @knightrider `Can't locate Gitolite/Rc.pm`... I had that with old `require` directive in my [`gitweb.conf.pl`](https://github.com/VonC/compileEverything/commit/7117962546d7fee0404f29e54720dbf4142c4ba9#L6R1). Do you have a `use Gitolite::Rc;` in your [`gitweb.conf.pl`](https://github.com/VonC/compileEverything/blob/master/gitweb/gitweb.conf.pl.tpl#L22-L27)? – VonC Aug 02 '13 at 13:16
  • I dont have a gitweb.conf.pl. Should I create it? Where would this be located? – knightrider Aug 02 '13 at 13:45
  • @knightrider first look in your gitweb where 'Rc' is mentioned. – VonC Aug 02 '13 at 13:46
  • I checked /usr/share/gitweb and /home/git/gitolite there is no Rc.pm – knightrider Aug 02 '13 at 13:51
  • @knightrider in http://pastebin.com/4bVFCCCx, you seem to be missing a [`DocumentRoot` (see link)](https://github.com/VonC/compileEverything/blob/master/apache/env.conf.tpl#L49-L59) which should point to your gitweb folder. In there you need to add a [`gitweb_config.perl` (link)](https://github.com/VonC/compileEverything/blob/master/gitweb/gitweb_config.perl) which is automatically interpreted by gitweb if found. That file can include a [`gitweb.conf.pl` (link)](https://github.com/VonC/compileEverything/blob/master/gitweb/gitweb.conf.pl.tpl) – VonC Aug 02 '13 at 13:58
  • My gitweb conf is in another file located in `/etc/apache2/conf.d/gitweb` The contents of that are here http://pastebin.com/6ztM4rk3. I have created the file `gitweb_config.perl` with the following contents http://pastebin.com/r6v0YCmw. I strong doubt the contents of the previous are correct. What should `$home_link_str` and `$site_name` be. Is my assignment to them correct. I also created `gitweb.conf.pl` with contents http://pastebin.com/RZzmREus – knightrider Aug 02 '13 at 14:20
  • Both the files were created in `/usr/share/gitweb`. It giweb.conf.pl I modified the variables `$ENV{HOME}` `$ENV{GL_BINDIR}` `$ENV{GL_LIBDIR}` to point to correct locations. I did not remove the ssl stuff in that file. The error is same as before – knightrider Aug 02 '13 at 14:22
  • @knightrider What is this http://pastebin.com/6ztM4rk3 conf file??? It doesn't look anything like http://pastebin.com/4bVFCCCx. You need one or the other, not both – VonC Aug 02 '13 at 14:27
  • May be I am completly wrong. This http://pastebin.com/6ztM4rk3 was created when I first created gitweb with gitolite. That file contains the ldap authentication for the web interface. The second one http://pastebin.com/4bVFCCCx I created by following your instructions. it was made by modifying httd.conf. It has no info about the gitweb. The second one was to handle `git clone ` etc from command line – knightrider Aug 02 '13 at 14:38
  • this is the new error I get in the terminal where I try to log in `http://pastebin.com/eu88jJsg` and this is the error on error log `http://pastebin.com/HdzKHCP1` – knightrider Aug 03 '13 at 08:42
  • what should be the values of `$home_link_str` and `$site_name` in gitweb_config.perl. Also There is Rc.pm file in my folder – knightrider Aug 03 '13 at 09:09
  • @Vnoc I found the problem. For some reason the lib was not copied to bin directory while installation. SO I create a link. Now ldap is working. But there is a problem while pushing back – knightrider Aug 03 '13 at 09:34
  • @knightrider progress. `$home_link_str` and `$site_name` are any value you would like to be displayed for the gitweb site. Those aren't likely to cause problem. – VonC Aug 03 '13 at 09:57
  • Yes atleast some progess. This is the error when I try to push `http://pastebin.com/N6kKmaP2`. I think if change the group of repository from git to ldap this will work. But is it a right thing to do ? – knightrider Aug 03 '13 at 10:07
  • Every this is messed up. I just added a new repostiory using gitlite. After I pushed it gitweb is showing `Can't locate gitweb.conf.pl in @INC (@INC contains: . /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl) at gitweb_config.perl line 5.` – knightrider Aug 03 '13 at 10:17
  • Also when I try to clone I am getting this error `FATAL: split conf set, gl-conf not present for 'testing'` – knightrider Aug 03 '13 at 10:19
  • @knightrider At this stage, I would go back to the gitolite installation/initialization: making sure that works first (no link added). – VonC Aug 03 '13 at 10:23
  • you mean reinstall gitolite. if yes can you give a link to the article. I was using this http://sharadchhetri.com/2013/05/31/how-to-create-own-git-server-with-gitolite-and-gitweb-in-ubuntu/. But apparently this wont set links properly – knightrider Aug 03 '13 at 10:26
  • @knightrider regarding the "`Can't locate gitweb.conf.pl`", what is the full content of your `gitweb_config.perl`? [See mine here](https://github.com/VonC/compileEverything/blob/master/gitweb/gitweb_config.perl). – VonC Aug 03 '13 at 10:26
  • @knightrider I like [my method for installing gitolite](http://stackoverflow.com/questions/17990402/gitolite-with-ldap-not-working/17991421?noredirect=1#comment26348502_17991421), but the [official doc is here](http://gitolite.com/gitolite/install.html). – VonC Aug 03 '13 at 10:28
  • Mine is like that `http://pastebin.com/LLXB679y`. I will try your method. I just need to run that script right? Or should I edit something? my git server username is `git`. Should I change something to speciy this – knightrider Aug 03 '13 at 10:30
  • @knightrider looks like mine. Try and use an absolute path in the '`use`' directive. Also http://stackoverflow.com/a/12513238/6309 is an interesting read. – VonC Aug 03 '13 at 10:41
  • @vnoc now the previous error is gone but its showing `FATAL: parse './gl-conf' failed: Permission denied`. Where is this file located – knightrider Aug 03 '13 at 10:45
  • @knightrider in each bare repo in `~git/repostories/xxx.git`. If you have installed again gitolite, try and declare a new repo, push `gitolite-admin` and see if that new repo is created, with `gl-conf` inside. – VonC Aug 03 '13 at 10:49
  • I did not install I was waiting for this question in previous post. I just need to run that script right? Or should I edit something? my git server username is git. Should I change something to speciy this – knightrider Aug 03 '13 at 10:55
  • @knightrider `git` is fine. In your case, follow the official doc I mentioned before. – VonC Aug 03 '13 at 10:57
  • The installation is complete. I updated all the config files. Gitweb is working now. git clone is also working. In the default testing repo there is gl-conf. I will add a new project later. First I would like to fix the current main problem, `git push`. The error on the terminal where I try to push is http://pastebin.com/ZgQpc7Dz. Output of log is http://pastebin.com/yZfmHe0K – knightrider Aug 03 '13 at 11:56
  • and output of `git config core.sharedRepository` is `true`. Also it possible to move to chat room now. This comment section is really big now – knightrider Aug 03 '13 at 11:58
  • Even more ssh using gitolite is working. But when I do git push, it works and it changes the permission of some files. When I fixed the permission gitweb is not showing any projects – knightrider Aug 03 '13 at 12:46
  • @knightrider I mainly manage that by making sure all my process are managed by the same user. – VonC Aug 05 '13 at 06:51
  • @VnoC Since gitolite is causing too much problem, especially changing the file permissions I am thinking of avoiding it completely. ie Just gitweb. Is this a terrible idea in my use case? are the any good alternatives to gitweb, which has inbuilt support for ldap? – knightrider Aug 05 '13 at 06:56
  • @knightrider I agree gitolite isn't mandatory, and is not linked to ldap. So (http + ldap) + gitweb should be enough. – VonC Aug 05 '13 at 06:57
  • I will try removing gitolite. I think your apache configuration had some comments to use this without gitolite. I will contact you if I again run into troubles. Thank you for all the help. – knightrider Aug 05 '13 at 06:59
  • Thanks to you. Everything is working except http. Over ssl I can add repositories push them etc, there is no problem at all. over http it shows some error. I think is a minor error. The error is `File does not exist: /var/www/hgit`. The httpd conf is http://pastebin.com/jnL6bZvg – knightrider Aug 05 '13 at 08:02
  • @knightrider seems [similar to my config](https://github.com/VonC/compileEverything/blob/master/apache/env.conf.tpl#L95-L112), but can you try to add a '`/`' at the end of the `ScriptAlias` line? `ScriptAlias /hgit /usr/lib/git-core/git-http-backend/` – VonC Aug 05 '13 at 08:30
  • I tried that the result is same. Is there any log I should check? – knightrider Aug 05 '13 at 09:12
  • @knightrider see also http://serverfault.com/a/393095/783 and http://serverfault.com/q/412314/783 as configuration examples. – VonC Aug 05 '13 at 09:21
  • There was some strange problem. After I restarted apache it was not working. But after restarting the system its working. Thankyou very much. Finally solved – knightrider Aug 05 '13 at 09:53
  • @knightrider Sounds great! I am still curious why gitolite wasn't playing along though... – VonC Aug 05 '13 at 10:21
  • I lost hope in gitolite. Not because of http access but because when I push it changes the file permissions. Without it, its working great. May its because I downloaded the latest branch – knightrider Aug 05 '13 at 12:32
  • @knightrider no, I don't have any issue with it, but I only use *one* account to manage everything, so I don't have permission issue. – VonC Aug 05 '13 at 13:08
  • hi I have new problem over http after I updated the system. It is showing `File does not exist: /etc/apache2/htdocs`. I followed the instructions on `http://cobwebs.id.au/?p=110`. Now it shows `File does not exist: /var/www/hgit`. Any idea of the same? – knightrider Aug 18 '13 at 23:47
  • I have gone back to previous stage. Now if I give port number in the url it shows error with `htdocs` otherwise it shows error with `hgit` – knightrider Aug 19 '13 at 00:03
  • @knightrider for any new issue, it is best to create a separate question, which would detail the new context (and have a link back to this question). – VonC Aug 19 '13 at 05:19
1

just try

ssh git@hostname-or-ip

This should not ask password; it can ask passphrase. This will also emit list of repositories you have access to.

BTW - username@localhost in git clone command is grossly wrong

forvaidya
  • 3,041
  • 3
  • 26
  • 33