作者:mobiledu2502889793 | 来源:互联网 | 2017-11-03 08:21
1.DownloadthesourcetreeofgitolitewhichispatchedbyJinagXin,aadvancedgitcontributerinchina.gitclonegit:github.comossxp-comgitolite.git2.Addagituserwhichisusedtoaccessgitserverforeachclientsinremotemachi
1. Download the source tree of gitolite which is patched by Jinag Xin, a advanced git contributer in china.
- git clone git://github.com/ossxp-com/gitolite.git
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