架设 gitolite 服务器


1. Download the source tree of gitolite which is patched by Jinag Xin, a advanced git contributer in china.



2. Add a git user which is used to access git server for each clients in remote machine.

sudo adduser --system --shell /bin/bash --gecos 'git version control' --group --disabled-password --home /home/gitolite gitolite



3. Back to the client and create a key pairs

cd ~/.ssh
ssh-keygen -t rsa -f id_rsa_gitolite
cd ~


4. copy the public key to the home directory of git user - gitolite in remote machine.

scp ~/.ssh/id_rsa_gitolite.pub mygitbox
ssh mygitbox
sudo cp id_rsa_gitolite.pub /home/gitolite
sudo chown gitolite:gitolite /home/gitolite/id_rsa_gitolite.pub


5. Become the user gitolite and add the public key into the list of authorized keys so that can be used to log as this user.

sudo su - gitolite
mkdir .ssh
chmod 700 .ssh
cat id_rsa_gitolite.pub >> .ssh/authorized_keys
chmod 600 .ssh/authorized_keys
rm id_rsa_gitolite.pub


If you are using debian, above commands can be replaced by "ssh-copy-id gitolite@server"


6. Remove the line PublickeyAuthentication "no" in /etc/ssh/sshd_config on remote machine if it exists then restart sshd


7. Remove the line PublickeyAuthentication "no" in /etc/ssh/ssh_config on client machine


8. Modify ~/.ssh/config

Host mygitbox
    User gitolite
    Hostname 10.42.43.13
    Port 22
    PreferredAuthentications publickey
    IdentityFile ~/.ssh/id_rsa_gitolite

 
9. Installation procedure on client machine

cd gitolite/src
./gl-easy-install gitolite mygitbox gitadmin


.ssh/authorized_keys will rename to old_authkeys and re-generate authorized_keys

New ~/.ssh/config shows:


10. Done

架设 gitolite 服务器_第1张图片 

你可能感兴趣的:(架设 gitolite 服务器)