Git private server

There are a few ways to host your own Linux server.

Git on Linux, few contributors, ssh access

This setup is maybe the simplier one, and it is suitable for very few contributors.

Assumptions

  • All contributors will have ssh access to the server

Prepare de server

First thing to do, is to create the group in the server for the contributors.

group add git-users

Next step, create the users for the contributors.

useradd -m -g [initial_group] -G [additional_groups] -s [login_shell] [username]

Using that template create the users with something like this:

useradd -m -g users -G git-users -s /bin/bash contributor1

Repeat for as many users as you need. Set the passwords

passwd contributor1

Create the repository

cd /usr/share

mkdir /usr/share/git-repos

git init –bare /usr/share/git-repos/project.git

Assign permissions

chown -R root:git-users /usr/share/git-repos/

It is now ready to accept push, pull and clone.

Clone it

git clone contributor1@[server-ip]:/usr/share/git-repos/project-git

Add a remote

git remote add local contributor2@[server-ip]:/usr/share/git-repos/project-git