Use gitolite Git repository management authority

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/mdykj33/article/details/102777289

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: fastestmirrorLoading 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 versionNothing to do

Check the SSH server public key:

查看是否存在/home/git/.ssh/authorized_keysfile. 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.pubid_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/gitoliteCloning into 'gitolite'...remote: Enumerating objects: 9646, done.remote: Total 9646 (delta 0), reused 0 (delta 0), pack-reused 9646Receiving 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 -altotal 32drwx------. 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 .bashrcdrwxr-xr-x. 2 git  git     6 Sep 28 23:21 bindrwxr-xr-x. 6 git  git   245 Sep 28 23:20 gitolitedrwx------. 6 git  git    57 Sep 28 23:33 .gitolite-rw-------. 1 git  git  7130 Sep 28 23:33 .gitolite.rcdrwxr-xr-x. 2 git  git     6 Sep 28 23:15 git-shell-commands-rw-------. 1 git  git    12 Sep 28 23:33 projects.listdrwx------. 4 git  git    51 Sep 28 23:33 repositoriesdrwx------. 2 git  git    56 Sep 28 23:33 .ssh

看到repositories目录下已经有了两个git仓库:

[git@git ~]$ ls -al repositories/total 0drwx------. 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.gitdrwx------. 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-adminCloning 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
  • repoOn 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.

  • masterAnd  devrepresentatives 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 ~

Guess you like

Origin blog.csdn.net/mdykj33/article/details/102777289