vqzatw
Last Updated: February 25, 2016
·
2.755K
· emi420

Your own Git server

If you need your own remote Git server, you can just create Git bare repositories in your Linux server, like this:

git init --bare /git/myRepo.git

And make the repository available to system users, using chmod to determine who can access to which files. Then, users can access via SSH:

git clone ssh://user@yourserver.com/git/myRepo.git/

This approach is fast and easy to implement, but insecure and complicated, because permissions on Linux can be tricky and disable console access while maintain SSH working for git command is not an easy task.

Gitosis

Is a great tool to deal with this type of work. You install Gitosis in your server and then clone a configuration project to your local machine, in which you can manage the Git server (users, repositories, groups) using git. All users, including admin, have access via the gitosis user, and that user has console access disabled.

First, use a package installer to install git-core and gitosis:

sudo apt-get -y install git-core gitosis

Initialize gitosis using your public key:

sudo -H -u gitosis gitosis-init < yourPublicKey.pub

Where yourPublicKey.pub is a copy of the public key from your local machine.

And, in your local machine, checkout the gitosis-admin branch:

git clone gitosis@yourserver.com:gitosis-admin.git

You can edit the configuration file:

vi gitosis-admin/gitosis.conf 

And add projects, users or groups.

After your're done, save the file and commit back:

git commit -a -m "New project, yeah!"
git push

More detailed info here:

https://help.ubuntu.com/community/Git

6 Responses
Add your response

195

This should be a blog post or article.
Awesome.

over 1 year ago ·
247

Thanks francisc!

over 1 year ago ·
1703

That's probably the exact same reason why you login to Github using the git user rather than your own account.

over 1 year ago ·
5336

Thanks Emilio Mariscal.......

over 1 year ago ·
5341

Nice roundup although I prefer https://github.com/sitaramc/gitolite over gitosis.

over 1 year ago ·
5353

got to agree with jan0sch

over 1 year ago ·