centos安装gitolite
安装基础包
yum install perl openssh git
yum install perl-Time-HiRes
创建git用户
useradd -d /home/git git
passwd git
在git用户家目录下安装gitolite
切换到git用户
# su – git
创建文件夹bin
$ mkdir bin
克隆gitolite源码
$ git clone https://github.com/sitaramc/gitolite.git
$ ls
bin gitolite
安装gitolite
$ ./gitolite/install -to /home/git/bin/
$ cd bin/
$ ls
commands gitolite gitolite-shell lib syntactic-sugar triggers VERSION VREF
配置gitolite管理员
生成管理员账户的公钥(此处指定本地root用户为管理员,键入回车使用默认值)
# ssh-keygen
复制管理的公钥
# cp .ssh/id_rsa.pub /tmp/admin.pub
切换回git用户,为gitolite配置管理员
$ /home/git/bin/gitolite setup -pk /tmp/admin.pub
Initialized empty Git repository in /home/git/repositories/gitolite-admin.git/
Initialized empty Git repository in /home/git/repositories/testing.git/
WARNING: /home/git/.ssh missing; creating a new one
WARNING: /home/git/.ssh/authorized_keys missing; creating a new one
$ ls
bin gitolite projects.list repositories
管理员日常管理
管理员clone管理库(此处为本地root用户)
# git clone [email protected]:gitolite-admin
Initialized empty Git repository in /root/gitolite-admin/.git/
The authenticity of host ‘192.168.213.130 (192.168.213.130)‘ can‘t be established.
RSA key fingerprint is d4:28:ca:66:58:b6:39:c1:aa:37:58:9a:5b:ed:50:05.
Are you sure you want to continue connecting (yes/no)? yes
# 此处因为第一次ssh连接,所以需要输入’yes‘
Warning: Permanently added ‘192.168.213.130′ (RSA) to the list of known hosts.
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
Receiving objects: 100% (6/6), 748 bytes, done.
remote: Total 6 (delta 0), reused 0 (delta 0)
# pwd
/home/git/gitolite-admin
# ls
conf keydir
创建库、添加用户
例如某lm用户访问git服务器上的myFirstRepo库
lm用户向git服务器管理提交自己的ssh无密码公钥
管理员将lm的公钥复制到 gitolite-admin/keydir/ 下
# cp lm.pub /home/git/gitolite-admin/keydir/
这里的XX.pub就是用户XX,及conf里的用户名,windows下通过putty-keygen生成
将蓝色的部分保存为XXX.pub,放到gitolite-admin/keydir/下,不是生成公钥的那个!私钥是通过生成私钥的按钮生成,之后在tortoiseGit里load这个私钥与git服务器通信。
windows用户生成密钥
可以使用putty的puttygen.exe文件来直接生成公钥和ppk,但是公钥是最上面显示出来的,而不是Save public key产生的。
另一种方法是使用msysgit中的ssh-keygen来生成: ssh-keygen -t rsa,然后在将密钥通过puttygen.exe来load,然后在Save private key来生成ppk文件
管理员创建myFirstRepo库,并给lm分配权限
# cd gitolite-admin/conf/
# vi gitolite.conf
默认内容为:
repo gitolite-admin
RW+ = admin
repo testing
RW+ = @all
下边定义myFirstRepo库,并且指定用户权限:
repo gitolite-admin
RW+ = admin
repo testing
RW+ = @all
@myGroup=admin lm
repo myFirstRepo
RW+ = @myGroup
注:此处@myGroup是一个组,给myGroup组赋予对myFirstRepo这个库的读、写、推送的权限(详细规则可参考gitolite的readme.txt)
管理员将对gitolite-admin的修改(建库、加用户)提交到git服务器
# pwd
/root/gitolite-admin
# git status
# On branch master
# Changed but not updated:
# (use “git add
# (use “git checkout —
#
# modified: conf/gitolite.conf
#
# Untracked files:
# (use “git add
#
# keydir/test123.pub
no changes added to commit (use “git add“ and/or “git commit -a“)
# git add *
# git commit -m “AddRepo:myFirstRepo;AddUser:test123″
[master 4c5a5d0] AddRepo:myFirstRepo;AddUser:test123
Committer: root
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:
git config –global user.name “Your Name”
git config –global user.email [email protected]
If the identity used for this commit is wrong, you can fix it with:
git commit –amend –author=‘Your Name
2 files changed, 6 insertions(+), 0 deletions(-)
create mode 100644 keydir/test123.pub
注:提示是建议设置用户信息(便于多人协作时辨别),可参照提示命令操作(其实git自动为你添加了)
# git push origin master
Counting objects: 10, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (6/6), 859 bytes, done.
Total 6 (delta 0), reused 0 (delta 0)
remote: Initialized empty Git repository in /home/git/repositories/myFirstRepo.git/
To [email protected]:gitolite-admin
48a7307..4c5a5d0 master -> master
客户验证
lm用户克隆myFirstRepo库
$ git clone [email protected]:myFirstRepo
Initialized empty Git repository in /home/test123/myFirstRepo/.git/
warning: You appear to have cloned an empty repository.
$ ls
myFirstRepo
来自 <https://www.cnblogs.com/kudosharry/articles/3709418.html>