Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to setup a GIT repository over LAN in Ubuntu OS.
I am able to setup a GIT repository, but not sure HOW TO expose the repository to other users in LAN.
As it requires a server, I installed OpenSSH-Server. But don’t know HOW TO configure it.

Please point me to correct resource to read from.

share|improve this question

migrated from Sep 14 '09 at 11:38

This question came from our site for professional and enthusiast programmers.

up vote 15 down vote accepted

First of all, you need to check your openssh setup on Ubuntu server: see this HowTo.

Then you can follow this article, which mainly recommend:

$ sudo apt-get install python-setuptools
$ mkdir ~/src
$ cd ~/src
$ git clone git://
$ cd gitosis
$ sudo python install
$ sudo adduser \
  --system \
  --shell /bin/sh \
  --gecos 'git version control' \
  --disabled-password \
  --home /home/git \

go into your /etc/ssh/ssh_config file and add git to the list of Allowed Users that can login.
copy your file over to your server somewhere (in our example we're using /tmp) and then run this command:

 $ sudo -H -u git gitosis-init < /tmp/
     Initialized empty Git repository in ./
 $ sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

From your local machine, test it out with this:

 git clone git@YOUR_SERVER:gitosis-admin.git

Configure gitosis for a new project. Use your favorite editor to create a new block under the gitosis one. It should look like this:

[group myrailsapp]
members =
writable = myNewApp

A couple of things to watch out in the above block.
First, make sure your name matches what's in your public key (that is, open your file and see that what the name says.
Second, make sure you spell writable correctly!

Once you're done, commit and push the changes up to the server.

$ git commit -a -m "created a new repository!"
$ git push
share|improve this answer
Note: if you are having problems with the, you can use Github. – Kazark Aug 29 '13 at 0:29

Your best way of doing that would be to run a ssh server and limit your users to use git-shell for their login shell. You can install an ssh server properly by either running one of the following commands if it has not already been installed.

sudo apt-get install openssh-server


sudo apt-get install dropbear

Then add /usr/bin/git-shell to /etc/shells by doing

sudo echo $(which git-shell) >> /etc/shells

Then use the git-shell instead of bash as your user shell. This will restrict the user to only being able to perform git operations when logging into the server instead of providing the user with a full she..

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.