5

I installed gitolite on my server using this tutorial. This falls under the "non-root" method.

It fails when I try to clone gitolite-admin back to my client. I get this error message:

git clone gitolite@server.com:gitolite-admin
Cloning into gitolite-admin...
fatal: The remote end hung up unexpectedly

Also:

git clone ssh://gitolite@server.com:gitolite-admin
Cloning into gitolite0admin...
Using username "git-upload-pack 'gitolite".
fatal: The remote end hung up unexpectedly

I have also tried appending .git to the end of the repo name, and I have also tried adding repositories/gitolite-admin (suggested by the errors in the tutorial linked above) and a combination of both of these and none work. I can find no results on google regarding the "Using username" bit, which intrigues me.

I can connect to the machine via ssh, and it tells me that I have access to R and W gitolite-admin. So, SSH is working?

simont
  • 68,704
  • 18
  • 117
  • 136
steve
  • 329
  • 1
  • 4
  • 9

2 Answers2

8

Check the ssh parts about gitolite: the fact that you can connect to server.com through ssh only means:

  • your ssh key is registered in server.com@~/.ssh/authorized_keys
  • that key isn't related to gitolite 'there is no "command=" option, which means "regardless of what the incoming user is asking to do, forcibly run this command instead").
    You are in an interactive session, able to execute any command you like.

What I don't like at all about the third-party tutorial is that it tries using the same name for git user and ssh non-root user

You should keep separate:

  • the non-root user (which isn't an account, just an ssh key, which will be linked to gitolite, with admin privileges to the gitolite-admin repo)
  • the hosting account, which should be 'git', not gitolite, precisely to avoid confusion between the two usage mode:
    • git (log on directly on server.com, no ssh here): interactive session needed to execute git command (like cloning on the server the gitolite repo, and executing gitolite/src/gl-system-install)
    • ssh git@server.com which will use your ~/.ssh/id_rsa(.pub) public and private keys, which, being the ones of the gitolite, will authorize you to clone the gitolite-admin repo and push back that repo

Again:
'gitolite' is not a true account, only a name authorized to execute commands on server.com as 'git' (the actual "hosting account", as in "hosting git services and repos").
All the other git users will also execute git commands on server.com as git.
And that particular user (gitolite) will be linked to gitolite authorization layer through the forced-command mechanism, with privileges setup during the gitolite installation in order to grant that 'user' rights to clone, modify and push back gitolite-admin repo.
(That is its only particularity compared to all the other ssh git users you will add: they won't have access to that specific git repo which is the gitolite-admin one)

Trying to name the two with the same name is just asking for trouble.

I don't like using the default naming convention for the public/private keys, so I prefer on the client defining those keys with the name of the intended user:

~/.ssh/gitolite.pub
~/.ssh/gitolite

Then I define a config file: ~/.ssh/config with in it:

host gitolite
     user git
     hostname server.com
     identityfile ~/.ssh/gitolite

(Note the user here: always git)
Then I can clone my gitolite-amin repo:

git clone gitolite:gitolite-admin
# modify locally
# git add -A ; git commit -m "my modifs"
git push origin master
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • The server I am using does not have any user logging on with a key pair authorization, so the key I am using, has not been added to anyone's ~/.ssh/authorized_keys. Now, the user I added to the server, gitolite, as in `useradd gitolite`, does have an ~/.ssh/authorized_keys, and in that file, I find my public key, my gitolite username (steve) and there is a command section. Furthermore, connecting to my server using the gitolite user is not an interactive session. It tells me what repos are available and then immediately logs me out. – steve Feb 18 '12 at 18:11
  • @steve: looks good, then. Can you try and define a ~/.ssh/config file on yur client side, and try a `git clone gitolite:gitolite-admin`? (just replace user git with `user gitolite`, even though I still find unsettling to consider `gitolite` as an account) – VonC Feb 18 '12 at 18:48
  • OK - Here's the lines from my ~/.ssh/config Host server.com User gitolite Hostname server.com PreferredAuthentications publickey IdentityFile "C:\Users\user name\.ssh\id_rsa" <- this key corresponds to the public key on the server, even though it has a different name. I'm not exactly sure what you meant by `git clone gitolite:gitolite-admin`, but I ran it and I got Host does not exist, unable to open connection. So then I ran the same commands from above, and I am still getting the same error. – steve Feb 19 '12 at 18:41
  • @steve: When you are declaring within a config file an 'host', you are declaring a shortcut. Instead of using `ssh://git@server.com/...`, you would use `gitolite:...` because the host '`gitolite`' would correspond to the hostname '`server.com`' with a specific private key (which name can be `xxx`, as long as you have its public key right alongside said private key, named '`xxx.pub`'). The name isn't important: it isn't transmitted. Only the content of the public key is. So don't declare '`host server.com`', that is not what the field host is for. It is for declaring an alias easier to remember – VonC Feb 19 '12 at 18:55
  • NEW Information! I decided to see what else I could figure out, and so I used a virtual machine to check to see if I could accomplish anything. I was able to add a user for the virtual client, and that user is capable of cloning the testing repo, that comes with gitolite. I tried that on my real client, and I can't even clone that, so it has to be a problem with the git setup I have on my machine. – steve Feb 19 '12 at 19:46
  • I dunno - I reinstalled git on my client, and I still have the same problems. Maybe I should juse give up on this and reinstall gitolite n the server, and then set everything up from my virtual machine? – steve Feb 19 '12 at 20:12
  • And thank you for explaining how the aliasing of hosts works! – steve Feb 19 '12 at 20:14
  • @steve: reinstalling it, by keeping separate the hosting account ('`git`') and the gitolite admin user ('`gitolite`'), can help. – VonC Feb 19 '12 at 20:20
1

For posterity, the fix is to make sure that GIT_SSH is not set to TortoisePlink.exe. Git can't use it.

Yuriy Gettya
  • 693
  • 10
  • 20