How to install and configure gitolite in centos6

Source: Internet
Author: User
Tags commit mkdir ssh install perl git clone


Two management tools are used on the git server, one is gitlab and the other is gitolite,

1. gitlab has powerful functions and a web management interface. For more information about how to install and configure gitlab nginx in linux, see gitlab.

2. gitolite is easy to install and has simple functions. It is not bad in general to create a repository and assign permissions.
Gitlab is suitable for frequent repository creation and personnel changes, whereas gitolite is more suitable.

1. Install GIT

# Yum install perl openssh git

Note that all commands starting with "#" are root accounts, and commands starting with "$" are not administrator accounts.
2. Install gitolite
1. Create a git User
# Adduser git
# Passwd git
2. Switch to the git User and create the installation directory.
 
# Su-git
$ Cd ~
$ Mkdir bin
3. Clone the gitolite source code.
 
$ Git clone https://github.com/sitaramc/gitolite.git
4. Generate the administrator's public key and private key, and use root as the administrator.
 
$ Exit // exit and switch to root. su root needs the password.
# Ssh-keygen // generate the public key and private key
# Cp/root/. ssh/id_rsa.pub/tmp/admin. pub
5. Install gitolite
# Su-git
$/Home/git/bin/gitolite setup-pk/tmp/admin. pub
6. The administrator downloads the management Library.
 
$ Exit // exit and switch to root. su root needs the password.
# Git clone git@192.168. *. *: gitolite-admin.git
 
3. Add a test account

# Adduser tank
# Passwd tank
# Su-tank
$ Ssh-keygen
Generate the user's public key and private key. We can also use PuttyGen in tortoisegit to generate the public key and private key,
In linux, the private key generated by ssh-keygen and the private key generated by PuttyGen cannot be used in a universal manner.
Save linux private key as ppk in windows
Save linux private key as ppk in windows

4. Add a repository and configure permissions

1. Add the public key to the management database.

# Cp/home/tank/. ssh/tank. pub/root/gitolite-admin/keydir/

2. Modify the configuration file and grant permissions
 
# Vim/root/gitolite-admin/conf/gitolite. conf
 
@ Test = zhangying tank test // defines a group with multiple persons separated by spaces. It is recommended that all groups be placed on the top for centralized management.
 
Repo gitolite-admin
RW + = admin
 
Repo testing
RW + = @ all
 
Repo blog // The repository name defined, that is, the git@192.168. *. *: blog. git
RW + = @ test // read/write
 
Repo test
R = @ test // read-only

3. Add user information to the management database
 
#/Root/gitolite-admin
# Git add *
# Git commit-m "add tank"
# Git push

In this way, the server can be set up, whether it is switching to the tank user in linux for clone or using tortoisegit in windows for clone.

 

Use gitolite to manage git servers


Gitolite: 2.2-1


Both the server and client are in ubuntu linux


Since gitosis is no longer updated, it is intended to migrate to gitolite. Since there are not many users in the project, we will not perform detailed migration here. We only need to install gitolite and reconfigure the users allowed to access it. The original library does not even need to be moved, however, we recommend that you clone and push the gitolite-admin database again to avoid management errors.


Through apt installation, gitolite uses the SSH key to authenticate users. However, you do not need to add users to the host, but use git, a restricted user on the server. The installation process requires switching between the client and the server. Pay attention to the instructions before the operation steps.
Server (ip: 192.168.1.254)


1. Install git


Sudo apt-get install git-core


2. Install gitolite


Sudo apt-get install gitolite


Here we use 2.2-1 in the software source, the latest on the https://github.com/sitaramc/gitolite.


3. Create a git User


Sudo adduser -- system -- shell/bin/sh -- gecos 'Git user' -- group -- disabled-password -- home/git
If the original gitosis has been created, you do not need to use it here.


4. Check whether the above is normal ^_^


Client (you also need to install git first)


5. Generate a key on the gitolite administrator's machine and rename the public key to comet. pub. scp is used to upload the key to the server.


Ssh-keygen-t rsa
Mv id_rsa.pub comet. pub
Scp comet. pub comet@192.168.1.254: comet. pub
Note: The public key file comet. pub contains only one line of content. If it is generated using puttygen in windows, multiple lines will be generated. The following prompt will be prompted during subsequent initialization:
WARNING: a pubkey file can only have one line (key); ignoring comet. pub
Perhaps you're using a key in a different format (like putty/plink )?
If so, please convert it to openssh format using 'Ssh-keygen-I '.
If you want to add multiple public keys for a single user, use
"User@host.pub" file names. See the "one user, your keys"
Section in doc/3-faq-tips-etc.mkd for details.
6. In ~ /. Ssh/config add the following content to connect to the server
Host 192.168.1.254
Compression yes
IdentityFile ~ /. Ssh/id_rsa


Server


7. Use comet. pub above to initialize gitolite
Switch to the git User before proceeding
Su-git
Gl-setup/home/comet. pub
Creating gitolite-admin...
Initialize empty Git repository in/home/git/repositories/gitolite-admin.git/
Creating testing...
Initialized empty Git repository in/home/git/repositories/testing. git/
[Master (root-commit) 0aa63a9] start
2 files changed, 6 insertions (+)
"Create mode 100644 conf/gitolite. conf"
Create mode 100644 keydir/comet. pub
The initialization is based on/usr/share/gitolite/conf/example. conf and example. gitolite. rc is generated under/home/git. gitolite. rc ,. gitolite, projects. list, repositories, generate two versions of gitolite-admin and testing libraries, and in. add comet to ssh/authorized_keys. pub file.


Client


8. Get the gitolite-admin project on the server. There are two folders: keydir and conf.
Git clone git@192.168.1.254: gitolite-admin
Since the public key of the comet user has been added to git User. ssh/authorized_keys, the git password is not required here.
Note: Here, gitolite-admin is the repositories/gitolite-admin in the git User root directory. Absolute paths such as/srv cannot be used, but soft links can be used.
9. Add a new jichuteam, user jichu, and project jichu and push them to the remote server.
Note: If the client is windows, use Puttygen to generate the public key and private key: the parameter is SSH-2 RSA, 1024-bit, add password as needed.
If you used ssh-keygen to generate a private key, Load the private key and save the private key in ppk format.
Copy the public key displayed by puttygen and save it as the *. pub file. Note that it is not "save public key". Make sure that the public key file contains only one line of content; otherwise, it is incorrect. Give the public key to the git administrator, and use the gitolite-admin method to add the public key to the git server, and set the permissions for the corresponding project.
Generate a key on the new client and put the public key in gitolite-adminkeydir. Here is Admin. pub.
Cd gitolite-admin/conf
Vi gitolite. conf
Change to the following content. repo indicates the corresponding project version Library, RW + indicates read/write, and Admin indicates the file name of Admin. pub, indicating users. Multiple users are separated by spaces.
Repo gitolite-admin
RW + = comet
Repo testing
RW + = @ all
Repojichu
RW + = comet Admin
Git push


10. Create the project root directory elsewhere, set the default user and mailbox, and add the master branch and remote server URL in. git/config.


Mkdir jichu
Cd jichu
Git init
Git config user. name Comet
Git config user. email iamcomet@3gcomet.com
Git remote add master git@192.168.1.254: jichu. git


11. develop in the jichu Directory. Here, log.txt (a new file must be created) is created, submitted to index, and "initial import" information is added and submitted to the local repository, finally, push to the remote server.
Echo "begin develop"> log.txt
Git add.
Git commit-a-m "initial import"
Git push master


Server


12. On the server's/home/git/repositories/, you can see the jichu. git version Library.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.