This site has been archived and will no longer be updated.
You can find my new profile at neilpahl.com. My new blog is at 808.ninja.
Created on Fri, 29 Jun 2012.
This is pretty much a sumary of what was already said at ...
http://git-scm.com/book/en/Git-on-the-Server-Setting-Up-the-Server
... plus a few customizations and a suggested method of how to init a bare git repo for a user that is restricted by git-shell.
Step 1)
Install Git server:
sudo apt-get install git-server
after installing git-server create a user account which will own the shared repo. Usually just using 'git' is ok, but if you are serving to different organizations, then you would liek to give them their own username so that they cannot access all the other projects ( I would prefix their username with git so that I can recognize why that user is on my system... something like gitjsdesign). If you're on a shared server or cloud, you can protect the data by encrypting their home folder... using (in Ubuntu at least)..
adduser --encrypt-home gitjsdesign
without encryption, you can use:
adduser gitjsdesign
step 2)
ask gitjsdesign to use ssh and create a public key which they can send(email) you. Add their public key to the authorized_keys file at /home/gitjsdesign/.ssh/authorized_keys. add your own public key in there too.
step3)
protect your shell by restricting their access.
find our where the git-shell is:
which git-shell
lets say we got /usr/bin/git-shell
now we edit the /etc/passwd file
sudo vi /etc/passwd
then change
gitsjdesign:x:1000:1000:,,,:/home/gitsjdesign:/bin/sh
to
gitsjdesign:x:1000:1000:,,,:/home/gitsjdesign:/usr/bin/git-shell
step 4)
create the project repo.
using your regular user account, go to the home directory of the git user,
cd /home/gitjsdesign/
initialize a bare repo... ** run sudo as gitjsdeign so that they own it.
sudo -u gitjsdesign git init ourProject.git --bare
Now, the user can go to their project root and run
git init git add . git commit -m 'initial commit' git remote add origin gitjsdesign@gitserver:ourProject.git git push origin master
PLEASE let me know if I'm doing something wrong, or if you have any suggestions or requests~
blog comments powered by Disqus