I want to create a shared team repository using Git in my machine (ubuntu 10.4), so our team can clone the code and pull/push etc...

But I found it seems I need to create ssh account for it. I am not familiar with the security of linux, so I wonder how to control the access right for this account. Say, I hope this ssh account only can access the git directory (read and write), for example, /home/camino/myproject, and any access to all the other directory should be denied.

Is it possible?

Thanks in advance for your help.

  • Setting up ssh accounts for all the users is indeed the best and easiest way to do this. I voted to move this question to superuser. – kubi Sep 28 '10 at 9:34

This is what Gitosis solves. The solution is a single user account (call it 'gitosis'), public-key access to it over ssh, and gitosis in the background checking those credentials per a configuration file.

| improve this answer | |
  • Absolutely gitosis. You don't need to (or even want to, most likely) create user accounts for each person. gitosis lets you configure your git server using git. It's fantastic. – Graham Perks Sep 29 '10 at 1:11

You can create user accounts on your box for your co-workers. By default they should not be able to access your local home directory. You can verify this by checking the file system access setting on /home/user (replace 'user' with actual user name)

drwxr-x--- 143 user user 8.2K 09-28 14:45 /home/user/

Here is a basic outline of what you should do:

  1. Create a new group named 'git'
  2. Add 'git' group to your current user name
  3. Create a new user account for each user and add 'git' to there group list
  4. Create a new directory tree from / where your git repo's will be stored
  5. Make sure the directories can be accessed by your 'git' user group
  6. Clone your working repo to a bare one, and push to the shared repo using ssh:

    git clone --bare ~/proj proj.git
    scp -r proj.git server:/git/USER/
  7. Add the shared repo to your working git project, so you can push/pull.

    git remote add origin ssh://HOSTNAME/git/USER/proj.git
    git config branch.master.merge refs/head/master

From this point, your remote users should be able to access your machine, login and clone the shared repo. They can also push/pull changes.

| improve this answer | |

Your Answer

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

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