I'm trying to get gitosis to work on my Ubuntu instance on EC2. I'm having a problem with getting the right key to work.

I SSH to my server using the key provided in the AWS console: it's a public key (using the SSH IdentityFile option). All pretty standard. I'm using the official Ubuntu 10.04 AMI.

The installation of gitosis creates a new user. I'm supposed to provide a public key from my local machine. This doesn't work. I'm getting "Permission denied (publickey)."

In an attempt to mend the situation, I tried using the private key from the server to initialize the repository or adding the public key to the authorized keys of the created using. I managed to move one step closer, but then I got "fatal: 'gitosis-admin.git' does not appear to be a git repository" when trying to clone the admin repository.

Update:

I found out that the problem occurred because I specified an IdentityFile for my server in the .ssh/config file. When I removed it, the cloning worked. However, now I need to specify it every time I try to SSH into the server from the terminal. Is there a way around this?

link|improve this question
feedback

1 Answer

up vote 1 down vote accepted

I found out that the problem occurred because I specified an IdentityFile for my server in the .ssh/config file. When I removed it, the cloning worked. However, now I need to specify it every time I try to SSH into the server from the terminal. Is there a way around this?

A couple.

  • You can load both keys into the SSH agent, and both will be used whenever needed.

    In Ubuntu, one should be running already, so just run ssh-add on both key files. (In fact, the GNOME Keyring component appears to load ~/.ssh/id_* automatically on logon.)

  • You can have two Host definitions in ~/.ssh/config: one for interactive use, one for Git.

    Host mybox
        Hostname foo.domain.tld
        IdentityFile ~/.ssh/ec2-key
    
    Host mybox-git
        Hostname foo.domain.tld
    
    git clone git@mybox-git:gitosis-admin.git
    
  • In some cases, Gitosis is unnecessary – git can push and pull over SSH without any special configuration. (Although Gitosis does help with authorization in multiple-user cases.)

link|improve this answer
Thank you for a full answer. I still don't understand something: if all users are pushing using the same git user, how can I distinguish between them in the GIT records. – zvikico Mar 30 '11 at 20:28
@zvikicio: I think you meant to ask about Gitosis, not Git. It's Gitosis that creates the git account. To distinguish between key owners, it uses a feature in OpenSSH that allows to force execution of different commands for different keys. (Just run cat ~git/.ssh/authorized_keys. Also read "AUTHORIZED_KEYS FILE FORMAT" in the manual page of sshd(8), where command="" is described.) – grawity Mar 30 '11 at 20:49
@zvikicio: Regarding Git itself, it doesn't care about the SSH account, or about SSH at all. The commiter's name and email are recorded at commit time, according to their own configuration. – grawity Mar 30 '11 at 20:50
I'm constantly surprised by SSH, just so versatile. Thanks again. – zvikico Mar 31 '11 at 5:39
@ gzvikico: gitosis is old now. you should try the more supported gitolite. – Jeff F. Apr 1 '11 at 18:50
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.