Install Gitosis
[@Server]
1. Download Gitosis from https://github.com/tv42/gitosis (or git clone git://eagain.net/gitosis )2. Install it by
cd gitosis
python setup.py install
If you get errors, try yum install python-setuptools
Generate SSH public/private key (If you don't have one)
[@Local]1. To generate a public/private key, run
ssh-keygen -t rsa
2. The newly generated public key will be at $Home/.ssh/ directory and named id_rsa.pub. Private key will be named id_rsa.
3. Upload your public key to server's /tmp directory
scp ~/.ssh/id_rsa.pub username@SERVER_IP_ADDRESS:/tmp/YourPublicKey.pub
Configure Gitosis
[@Server]
1. Create a user to own the repositories, usually called git
1. Create a user to own the repositories, usually called git
adduser git
2. Create the repository and add YourPublicKey into authorized keys
sudo -H -u git gitosis-init < /tmp/YourPublicKey.pub
Configure the permissions
[@Local]1. To configure who can access to your repositories, clone gitosis-admin first and then edit gitosis.conf in gitosis-admin directory
git clone git@SERVER_IP_ADDRESS:gitosis-admin.git
cd gitosis-admin
vi gitosis.conf
2. Add a repository, TestProject, and make user Howard has full access to it.
[New group]
members = Howard
writable = TestProject
3. Get Howard's public key, Howard.pub, from Howard and put it into keydir of gitosis-admin
cp Howard.pub keydir
4. Once done, commit it and push to remote server.
git commit -m "Give Howard full access to TestProject"
git push
Create the repository TestProject
[@Local]
1. User Howard creates the TestProject, initialize it and push it to remote server
mkdir TestProject
cd TestProject
git init
git remote add originServer git@SERVER_IP_ADDRESS:TestProject.git
// create files, git add . and commit
git add .
git commit -m "Initial commit"
git push originServer master:refs/heads/master
2. Now TestProject is created and available on server
3. To allow user Sibo accessing TestProject, edit gitosis.conf of gitosis-admin and add Sibo to members of [New group] and put Sibo's public key into keydir of gitosis-admin
4. Commit it and push it remote server and now Sibo will be able to clone TestProject from remote server
[@Sibo Local]
git clone git@SERVER_IP_ADDRESS:TestProject.git