Git is a kind of a version control system which allows users to keep their project information safely in repositories. In this case, I will be using Gitosis for this setup, Gitosis is a tool written for Git that helps in the setup of secure access controlled repositories. It will manage multiple repositories under one user account on the host machine. Using SSH keys to identify users, your repositories will be securely accessed and controlled. One large advantage to Gitosis is that your users will not need shell accounts on the machine to access repositories, they will however speak to a singular account what will not allow arbitrary commands. Now let's see how gitosis can install in to your Ubuntu server.
Installing Gitosis
First of all you should have installed Git.
sudo apt-get install git-core
By cloning the gitosis directory from "eagain.net" you will get the gitosis directory on your home page. Follow these lines to do it,
cd ~/
git clone git://eagain.net/gitosis.git
Now you better move that folder to /usr/local
sudo mv gitosis/ /usr/local
Now go to Gitosis folder.
cd /usr/local/gitosis/
If you haven't installed python in your computer get it installed.
sudo apt-get install python-setuptools
Then, you can run the setup.py file which is in this directory.
sudo python setup.py install
Now you are successfully installed Gitosis on your Linux server.
Next, you have to create user called "git". "git" is the repositories holding real user. It creates in a way that users to identify through ssh-keys. Anyone can't login through entering password.
sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /home/git \
git
gitosis-admin
Now let's initialize the gitosis and begin with adding an administrator to git repository. As a convention we used to create administrator account on the same server/computer. Because administrator has the super power of creating new repository, users and so on.
To identify administrator, you need to create create ssh key and initialize gitosis with that key. So you will add as the administrator.(janaka is the user, versioncontrol is the name of the linux server)
janaka@versioncontrol~$ ssh-keygen -t rsa
Keep blank for the parse phrase of the key. Found this generated key pair at /home/janaka/.ssh/ as id_rsa(private key) and id_rsa.pub(public key).
Since janaka@versioncontrol wants to the admin and versioncontrol is the git server itself. You can directly initialize with this key.
sudo -H -u git gitosis-init < /home/janaka/.ssh/id_rsa.pub
If your admin wants to be another user, generate this kind of key pair and copy it some where at versioncontrol(i.e. /tmp/id_rsa.pub). In this case,
sudo -H -u git gitosis-init < /tmp/id_rsa.pub
If you are success then it will give,
Initialized empty Git repository in ./
Initialized empty Git repository in ./
Congratz, Now you are the gitosis-admin....!!!!
Now you need to make executable the post-update hook. Run following command.
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
Its ready to take your admin clone..............
git clone git@YOUR_SERVER_HOSTNAME:gitosis-admin.git
In my case YOUR_SERVER_NAME is "localhost". If you (admin) from another host, give the ip of the linux server/machine(versioncontrol).
Now have go to cloned gitosis-admin directory.
janaka@versioncontrol~$ cd gitosis-admin
Have a look at the list,
You will found "gitosis.conf" file and "keydir" directory.
Have a look at the gitosis.conf file,
vi gitosis.conf
[gitosis]
[group gitosis-admin]
writable = gitosis-admin
members = janaka@versioncontrol
Now lets see how to add users and creating new repositories.
Since this post getting longer, Follow Next post.
click hereAdding Windows users to the gitosis and Many more