Installing git on your slicehost and managing it with gitosis
FINAL FINAL UPDATE: Here is the method I prefer now.
FINAL UPDATE: The following is a mind dump. It might be useful, but it is not longer the exact path I took.
Instead I followed the scientist article, but when it came to creating the git user I followed the slicehost article for ubuntu (which I am on).
—
Most all of this comes from the excellent article by scientist on hosting git repositories the easy and secure way with some adjustments for my own setup that you might find useful to get you started, especially if you’re a newb at this like me.
If you hosting your private projects on github is becoming to expensive you can do the following and host your projects with git on slicehost (or any vps for that matter) using gitosis.
First, let’s install git on our server.
I recommend installing from source. Some people ran into problems using apt-get (source)
# 1.5.6 as of Aug 14th, 2008
sudo apt-get remove git git-svn mkdir ~/sources cd ~/sources wget http://kernel.org/pub/software/scm/git/git-1.5.6.tar.bz2 sudo apt-get build-dep git-core tar xjf git-1.5.6.tar.bz2 cd git-1.5.6/ ./configure make sudo make install
Test that git is installed.
git --version # git version 1.5.6
Good. Now you can delete all the contents of the ~/sources directory if you’d like.
Second, let’s install gitosis. (source)
cd ~/src git clone git://eagain.net/gitosis.git sudo apt-get install python-setuptools cd gitosis sudo python setup.py install #this hung me up for a while. I thought gitosis was installed, but it wasn't. I had to run sudo.
UPDATE: I just used my standard user already setup on slicehost.
After that installs setup your user. It could be different than ‘git’, but let’s just use ‘git’ as the user.
sudo adduser \
--system \
--shell /bin/sh \
--gecos 'git version control' \
--group \
--disabled-password \
--home /home/git \
git
Now copy your ~/.ssh/id_rsa.pub on your LOCAL COMPUTER to your server.
# on your LOCAL computer cd ~/.ssh cat id_rsa.pub #copy and paste what spits out
# on your slicehost server cd /tmp sudo nano id_rsa.pub # paste in what you copied from your local computer
Now let’s put your public SSH key into gitosis’ permission
cd ~
sudo -H -u scottmotte gitosis-init < /tmp/id_rsa.pub
sudo -H -u git gitosis-init < /tmp/id_rsa.pub
Next
sudo chmod 755 /home/scottmotte/repositories/gitosis-admin.git/hooks/post-update
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update
Then back on your local machine account for the fact that I run ssh on a different port (put your port here)
sudo nano ~/.ssh/config
put this inside
Host www.example.com
Port 32767
UPDATE: The above didn’t work for me like the scientist post on hosting git repositories the easy and secure way said so I took a look at the git clone documentation and realized I could put ssh:// in front of the git clone string. Then I was able to add the port at the end of the string without it crapping out.
It didn’t work because I’m retarded and was doing sudo nano ~/.ssh/config on my server rather than locally. Make sure you do this locally.
cd ~/documents/code git clone scottmotte@209.1.1.xxx:gitosis-admin.git or git clone ssh://scottmotte@209.1.1.xxx:32767/home/scottmotte/repositories/gitosis-admin.git

Scott | September 14, 2008
This is an easy way to get going with a git server. http://blog.commonthread.com/2008/4/14/setting-up-a-git-server
Scott Motte » Blog Archive » How to setup a remote git server | September 19, 2008
[...] Some is taken from my attempts at using gitosis [...]