vqzatw
Last Updated: February 25, 2016
·
2.559K
· emi420
Image

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

Say Thanks
Respond

6 Responses
Add your response

195
529a291a6eb6205d850ac47d2c38b24c

This should be a blog post or article.
Awesome.

over 1 year ago ·
247
Image

Thanks francisc!

over 1 year ago ·
1703
Ea20769072a6038d72fba0cc2806b479

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
6f354f97b8b6325fae01a9d4f2d73c80

Thanks Emilio Mariscal.......

over 1 year ago ·
5341
2aaae7041aca85da930bcaf14d6768d2

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

over 1 year ago ·
5353
Meteor

got to agree with jan0sch

over 1 year ago ·
Filed Under