views:

46

answers:

1

I am trying to get a git repository up and running and installed git and gitosis on my remote ubuntu 8.04 server. I also have git running on my local ubuntu 10.04 machine.

After alot of trying to get it all to work I managed to get the ssh keys to work. When I type:

ssh [email protected]

it returns:

PTY allocation request failed on channel 0

ERROR:gitosis.serve.main:Need SSH_ORIGINAL_COMMAND in envirement.

Connection to 123.456.789.1 closed.

As far as I understand this means I succesfully connected to the server and the ssh key got accepted, but because it didn't get any commands it closes te connection.

When I try to get the repo:

sudo git clone [email protected]:gitosis-admin.git

It returns:

Initialized empty Git repository in /home/git/repositories/gitosis-admin/.git/

[email protected]'s password:

The problem is, I don't have a password or phrase set, nor does it accept an empty password or the server password or my local's machine password. I understand it should'nt at all ask for a password because it should accept the ssh key (without a passphrase) and start downloading.

From this pointon I have no idea how to get the remote repo to my local machine so I can start using git. I hope someone can point me in the right direction.

A: 

The authentication worked in your first test (ssh git@server). If authentication had failed (or stalled with a prompt) you would never have seen a message from gitosis. The warning and error you reported are to be expected when you try to do a normal, non-command ssh instead of letting git use ssh internally.

However, you did your clone in a slightly different environment (under sudo). The problem is probably that the ssh under sudo is not using the private key that the non-sudo, test ssh was using. In my testing, sudo ssh always uses files from ~root/.ssh, even if HOME points to a normal user’s home directory.

Solutions:

  • Forego the use of sudo for cloning the repository.
  • Generate another SSH key-pair as root and add its public component to your gitosis configuration.

There is one other way, but it is an ugly one; I will only leave a hint about it because it seems like such a bad idea to me. You could have root abuse its power to read the other user’s private key file (you would still have to type the passphrase if it has one).

Chris Johnsen
Tnx!! I've spent 2 days trying to get this to work.... and the solution was so simple. Removing the sudo fixed the problem and have my git repository now up and running and in use. :-)
DivZero