4
  • I have a 'git --bare' repo on a linux machine.
  • I wish to allow another user from a different machine to push/pull to it.
  • I have their ssh key.

Is there some way I can allow them to execute the command,

git clone ssh://user@server:/home/user/name.git

At the moment, I simply added their ssh key to my authorised keys... but that's not ideal. Searching around I only find suggestions for either moving to github or having a dedicated server with all the ssh keys for access (neither desirable).

Ideal would be if in the name.git directory I could execute something to add an ssh-key as an authorised pusher/puller,

git add --ssh <key> #not a real command

I'm on GNU bash, version 4.1.2(1)-release (x86_64-redhat-linux-gnu) with git 1.7.1.


Update: comments about gitolite led me to find this post which part solves my problem by using ssh 'authorized_key file formats' (manual) to allow only git-shell access. ssh-key-user now has access to only git folders, but I have not restricted their access to specific repo(s).

  • 3
    I think "gitolite" would be your friend. It uses ssh pubkey auth, has a fairly simle permission-system, and is easily configurable. In fact, you publish keys and premissions by editing the "gitolite-admin" repository, and pushing it to the server. github.com/sitaramc/gitolite.git – gerhard d. Mar 10 '16 at 15:50
  • I simply added their ssh key to my authorised keys Do the user connects through its own account? – A.L Mar 11 '16 at 0:39
  • 1
    @gerhardd.: Thank you for pointing me to gitolite! It looks very useful, but unfortunately I do not have root access, nor a 'fresh user id' that they mention as important. I still need to maintain my existing .ssh/authorized_keys file. I stumbled across git-shell too, but it seems similar to gitolite as I need to be able to add users to a machine (I think)... rather than just allowing me to provide git clone/push/pull access, for a particular ssh-key, to my git repo on my machine. – Sonke Hee Mar 11 '16 at 15:32
  • @A.L: I believe the user connects from a different machine and does not have an account on the server where my git repo is. My git repo is on a HPC cluster (so I have little admin control) and my colleague would access it from their work computer (which is another cluster, managed by someone else). I hope that answers it, I am not as clear in my head about Linux things as I should be. – Sonke Hee Mar 11 '16 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.