现在一般安装的linux系统都会自带git代码仓库服务器,如果使用git原生的权限管理则需要修改每个repo的配置文件。同时如果使用到了ssh还得把每个都放到authorized_keys文件中,这还会会带来一定的安全隐患。这样我们可以使用一个git的权限管理小插件gitolite。
系统要求
- Any Unix system with a posix compatible "sh" and a sane file system.
- Git version 1.6.6 or later.
- Perl 5.8.8 or later (see https://lwn.net/Articles/348084/ if this does not seem to be enough).
- Openssh (almost any version). Optional if you're using smart http.
- A dedicated Unix userid to be the hosting user, usually "git" but it can be any user, even your own normal one. (If you're using an RPM/DEB the install probably created one called "gitolite").
SSH配置
验证服务器ssh服务
先在git服务器生成一对密匙,然后通过服务器用户ssh到服务器,以确认服务器的ssh服务争取。需要注意的是以下两点:
- 需要对.ssh文件夹和.ssh/authorized_keys授权
- 如果系统没有自动将私钥加载,可以使用ssh-add命令
[git@localhost ~]$ ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/git/.ssh/id_rsa):
Created directory '/home/git/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/git/.ssh/id_rsa.
Your public key has been saved in /home/git/.ssh/id_rs