huntout.me

Install gitosis on Ubuntu

Feb 13, 2014

How to install gitosis on Ubuntu?

Install dependencies

apt-get update
apt-get uggrade
apt-get install openssh-server git-core python-setuptools
ps -e | grep ssh
dpkg --get-selections | grep -e 'openssh-server\|git-core\|python-setuptools'

Install gitosis

cd /tmp
git clone https://github.com/tv42/gitosis.git
cd gitosis
python setup.py install

Copy your ssh public key to server

# localhost
scp ~/.ssh/your_id_rsa.pub root@YOUR_SERVER:/tmp

Add a git user, then init gitosis with it

sudo adduser \
  --system \
  --shell /bin/sh \
  --gecos 'gitosis user' \
  --group \
  --disabled-password \
  --home /home/git \
  git
sudo -H -u git gitosis-init < /tmp/your_id_rsa.pub
sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update

For now, gitosis uses the HOME environment variable to locate where to write its files. If you use sudo -u without -H, sudo will leave the old value of HOME in place, and this will cause trouble. There will be a workaround for that later on, but for now, always remember to use -H if you're sudoing to the account. (gitosis)

Config gitosis on localhost

# localhost
git clone git@YOUR_SERVER:gitosis-admin.git

For more config detail, please reference the Git Book中文).