Quantcast
Channel: Site5 KnowledgeBase » Programming Tools
Viewing all articles
Browse latest Browse all 9

Installing and setting up Gitosis

$
0
0

Step 1) First we need to generate the SSH RSA key pair.

Linux Users

Run the following command…

ssh-keygen -t rsa -f USERNAME

Windows Users

Complete steps 1 through 11 of our Windows SSH Key article by clicking here.

Step 2) Connect to your account using SSH.

Step 3) We now need to create a file called id_rsa.pub in the home directory for your account on the server, this file will hold our public key. An easy way to do this is to open the nonexistant file in nano.

nano id_rsa.pub

Paste the PUBLIC key into the file and save (To save in nano, press Ctrl+X, type Y, then press Enter). Make sure that the key is on one line and one line only. Sometimes when a key is pasted, it will split into 3 lines, this will not work.

Step 4) Next, we need to add our key to the authorized_keys file. To do this, run the following command…

cat id_rsa.pub >> ~/.ssh/authorized_keys

If it gives you an error that says the directory does not exists simply run the following command and retry.

mkdir ~/$home/.ssh

Step 5) Now we need to make changes to our .bash_profile. Open the file using your preferred text editor (we will use nano) and make the following changes…

nano .bash_profile

Replace the PATH with the following…

PATH=$HOME/bin:$PATH

Now, add the following line below it…

PYTHONPATH=$HOME/lib/python2.4/site-packages

Next, we need to change the export line…

export PATH PYTHONPATH

Save your changes and close the file. Once the file has been closed, we need to tell the server that it was changed by running the following command…

source ~/.bash_profile

Step 6) Next we need to modify our bashrc file. To do this, simply run the following commands (make sure to change USERNAME with your actual username).

echo "export PATH=$HOME/bin:$PATH" >> .bashrc
echo "export PYTHONPATH=/home/USERNAME/lib/python2.4/site-packages" >> .bashrc

Step 7) Now we need to setup virtual python so we can install Gitosis. To do this, run the following commands…

mkdir ~/src
cd ~/src
wget http://peak.telecommunity.com/dist/virtual-python.py
python virtual-python.py

Step 8) It’s time to install Gitosis itself…

git clone git://eagain.net/gitosis.git

If that does not work, try the following source…

git clone https://github.com/tv42/gitosis.git
cd gitosis/
python setup.py install --prefix=$HOME
cd

Step 9) Gitosis should be fully installed at this point. It’s time to use your public key from earlier to initialize gitosis.

gitosis-init < id_rsa.pub

You should see a message telling you that your Git repository has now been reinitialized.

Step 10) Now we need to change permissions on the post-update hook.

chmod 750 $HOME/repositories/gitosis-admin.git/hooks/post-update

That’s It! The following section will tell you how to connect and clone from our new Gitosis setup.

Linux Users

git clone --branch master USERNAME@domain.com:~/repositories/gitosis-admin.git

Windows Users

If you plan on using TortoiseGit, you can use the following steps.

Navigate to the folder you wish to use for projects (For example – C:\projects) and right click. This will open up a pop up menu. Towards the bottom you should see “Git Clone…”. Select that and enter the following details (taking careful note of replacing USERNAME@domain.com and mykey with your information).

Type: Web (Drop-down menu on the right)
URL: USERNAME@domain.com:~/repositories/gitosis-admin.git
Load Putty Key: C:\mykey.ppk

To further explain the above: USERNAME is going to be the primary user on your account. So, if your username is “bob” and your domain is “bobsdomain.com” it would be “bob@bobsdomain.com” for the first part of the URL.

On Windows, the “mykey.ppk” file is going to be the name of the private key that you generated earlier in this tutorial. The location will vary depending on where you saved it, so make sure you take note of where the file is located. If you need help converting the SSH key to PPK format, please see our dedicated article on the subject by clicking here.

Once you have entered the correct information, select “OK” from the bottom of the window. If the transfer was successful, then you should see a “Success” message at the bottom and there will be a “keydir” directory and “gitosis.conf” file in the sub-directory where you performed the pull.

Congratulations on setting up gitosis and doing your first pull from master! From here you can setup additional branches, and add additional repositories accordingly. For additional information on using Gitosis, see the official Git and Gitosis documentation.


Viewing all articles
Browse latest Browse all 9

Trending Articles