原文地址:http://songgz.iteye.com/blog/1166854
第一步:安装Git和Gitolite
- server> sudo apt-get install git-core
- server> sudo apt-get install gitolite
第二步:安装ssh-key
1.安装openssh
- server> sudo apt-get install openssh
2.在服务器上创建git用户
- server> adduser –system –shell /bin/bash –group git
- server> adduser git ssh
- server> passwd git
3.在客户端生成ssh-key
- client> ssh-keygen
- Generating public/private rsa key pair.
- Enter file in which to save the key (/home/davem/.ssh/id_rsa):
- Enter passphrase (empty for no passphrase):
- Enter same passphrase again:
- Your identification has been saved in /home/davem/.ssh/id_rsa.
- Your public key has been saved in /home/davem/.ssh/id_rsa.pub.
- The key fingerprint is:
- 61:bf:f5:2d:f6:ed:cd:10:b7:0c:be:5d:4d:8f:a3:0d davem@client
4.上传公共key到服务器
- client> scp ~/.ssh/id_rsa.pub git@server:/tmp/davem.pub
5.在服务器上导入公共key
- server> gl-setup /tmp/davem.pub
第三步配置Gitolite添加用户和git项目
1.下载配置文件
- client> git clone git@server:gitolite-admin
2.进入gitolite-admin目录编辑conf/gitolite.conf文件
- client> cd gitolite-admin
- client> sudo nano conf/gitolite.conf
加入mytest项目,如下
- repo mytest
- RW+ = @all
提交更改
- client> git commit -m “Added mytest repo” conf/gitolite.conf
- client> git push
3.拷贝其他用户的公共key到keydir目录
- client> cp ~/Downloads/another.pub keydir/
提交更改
- client> git add keydir/another.pub
- client> git commit -m “Added another as a user” keydir/another.pub
- client> git push
第四步测试
- client> git clone git@server:mytest
成功!