How Git management authority it? GIT SVN itself does not provide a similar administrative privileges, use gitolite to manage. This paper tests under CentOS7 environment.
Perl installation packages associated gitolite dependent:
[root@git ~]# yum install 'perl(Data::Dumper)'
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
...... | 6.8 MB 00:00:01
Package perl-Data-Dumper-2.145-3.el7.x86_64 already installed and latest version
Nothing to do
Check the SSH server public key:
查看是否存在/home/git/.ssh/authorized_keys
file. If there is, then the renamed (for example: authorized_keys.bak).
Create a client key pair:
[root@client .~]# ssh-keygen -t rsa -C "[email protected]"
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:jPwVAK1111ip6/mbFbuyg113wyIcl1yX7OYb7113RLg [email protected]
The key's randomart image is:
+---[RSA 2048]----+
| .+oo |
| o o |
| . .... |
| = +. +. . |
| +.=o1o. . . |
| .. ++ .o o |
| .+ oo..o. 2...|
| oo*oo.o .o ....|
| .+o=1.o...++ . |
+----[SHA256]-----+
Upload the client's public key to the SSH server (/ home / git / directory, the file name from the name of your xxx.pub):
[root@client ~]# scp /root/.ssh/id_rsa.pub [email protected]:/home/git/admin.pub
id_rsa.pub 100% 400 148.9KB/s 00:00
Git user to switch to:
su git
Installation configuration gitolite:
[git@git ~]# cd /home/git/
Download gitolite:
[git@git git]# git clone https://github.com/sitaramc/gitolite
Cloning into 'gitolite'...
remote: Enumerating objects: 9646, done.
remote: Total 9646 (delta 0), reused 0 (delta 0), pack-reused 9646
Receiving objects: 100% (9646/9646), 3.01 MiB | 18.00 KiB/s, done.
Resolving deltas: 100% (5987/5987), done.
把上传到服务器的管理员的公钥setup到gitolite:
[git@git ~]$ /home/git/gitolite/src/gitolite setup -pk 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/authorized_keys missing; creating a new one
(this is normal on a brand new install)
查看目录:
[git@git ~]$ ls -al
total 32
drwx------. 8 git git 241 Sep 28 23:33 .
drwxr-xr-x. 3 root root 17 Sep 2 06:24 ..
-rw-r--r--. 1 git git 400 Sep 28 23:08 admin.pub
-rw-r--r--. 1 git git 18 Oct 31 2018 .bash_logout
-rw-r--r--. 1 git git 193 Oct 31 2018 .bash_profile
-rw-r--r--. 1 git git 231 Oct 31 2018 .bashrc
drwxr-xr-x. 2 git git 6 Sep 28 23:21 bin
drwxr-xr-x. 6 git git 245 Sep 28 23:20 gitolite
drwx------. 6 git git 57 Sep 28 23:33 .gitolite
-rw-------. 1 git git 7130 Sep 28 23:33 .gitolite.rc
drwxr-xr-x. 2 git git 6 Sep 28 23:15 git-shell-commands
-rw-------. 1 git git 12 Sep 28 23:33 projects.list
drwx------. 4 git git 51 Sep 28 23:33 repositories
drwx------. 2 git git 56 Sep 28 23:33 .ssh
看到repositories目录下已经有了两个git仓库:
[git@git ~]$ ls -al repositories/
total 0
drwx------. 4 git git 51 Sep 28 23:33 .
drwx------. 8 git git 241 Sep 28 23:33 ..
drwx------. 8 git git 181 Sep 28 23:33 gitolite-admin.git
drwx------. 7 git git 162 Sep 28 23:33 testing.git
Administrators can set the default remote management of warehouse gitolite-admin to directly clone git to manage local services:
[root@client git]# git clone [email protected]:gitolite-admin
Cloning into 'gitolite-admin'...
remote: Counting objects: 6, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 6 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (6/6), done.
Use the tree command to see the directory structure (the absence of such a command, you need to install yum install tree):
[root@client git]# tree gitolite-admin/
gitolite-admin/
├── conf
│ └── gitolite.conf
└── keydir
└── admin.pub
2 directories, 2 files
among them:
conf: is the configuration folder.
keydir: client public folder, all need to access the GIT into the public needs here. (Note that the file name format: username.pub, username as the user name when configuring permissions.)
Configuring a user read and write permissions (modified conf folder gitolite file) to the warehouse:
repo gitolite-admin
RW+ = admin
repo testing
RW+ = @all
-
repo
On behalf of warehouses mean, if a newly added repo, on behalf of the server to create a new empty warehouse, the warehouse will be created automatically push to the server later. -
RW
On behalf of readable and writable. -
@all
On behalf of everyone. -
master
Anddev
representatives of branch
Here you can reference SVN permission settings.
Can be modified, the administrator can commit changes to the server to take effect.
Briefly here, more self-test ~