Install the GIT server with private key authentication on centos 6.2

Source: Internet
Author: User
A. installer file

Sudo Yum install git Python-setuptools

CD/OPT

Sudo git clone https://github.com/res0nat0r/gitosis.git

CD gitosis/

Sudo Python setup. py install

B. Add a git user

Note: Do not set a password for git users so that they cannot log on.

Sudo adduser-M git

After the GIT user is successfully created, You need to log on to the root account before Su-git.

C. Generate a public key/private key pair on the client

First, install the GIT client and tortoisegit on the client machine (take windows as an example). First, generate a public key private key pair through git bash (leave blank parameters to be entered ):

Ssh-keygen

This command will be in the current user directory. the id_rsa and id_rsa.pub files are generated in the SSH directory. To enable tortoisegit to use the private key, you also need to use the puttygen tool of tortoisegit to generate the putty private key based on the id_rsa file and save it. PPK file:

D. initialize the gitosis Environment

First, you need to upload the generated public key to the server, open the id_rsa.pub file, and check the Last User Name. For example, the. Pub file I generated is like this:

Ssh-rsaAAAAB3NzaC1yc2EAAAABIwAAAQEAzX7 // drawing + drawing/drawing + J/zifazstjepn/drawing + drawing/vllydirrq1uh/fmzouwblr8 + drawing + 7h5w + drawing/khfc/drawing + yrtew + drawing = wuyf @ wuyfwin

So rename the public key file name to the wuyf@WUYFWIN.pub and upload it to the server, such as the/tmp directory, and then use this user to initialize gitosis:

Sudo-H-u git gitosis-init </tmp/wuyf \ @ wuyfwin. Pub

At this time, under the repositories directory of the GIT main directory, the gitosis-Admin repository for managing git accounts has been initialized.

E. Clone and configure the gitosis-Admin Repository

Now we can clone the gitosis-Admin repository to the local machine and configure it. Note that the private key in PPK format generated above needs to be loaded in the tortoisegit client:

If you want to add other users, execute the above steps C generate a public key private key pair on the client on other user machines, and. add the pub Public Key to the keydir directory of the gitosis-Admin repository. configure the corresponding group in the conf file. The following is an example of gitosis. conf configuration:

[Gitosis]

 

[Group gitosis-admin]

Writable = gitosis-Admin

Members = wuyf @ wuyfwin

 

[Group test]

Writable = maventestcitest

Members = wuyf @ wuyfwin XXX @ yyy

F. Create another warehouse

Use the root user to remotely log on to the server and switch to the GIT User:

Su-

Su-Git

Cd ~ /Repositories

Mkdir test. Git

CD test. Git

Git init -- bare

The repository can be cloned and used on the customer's machine. The repository address is as follows:

Git @ git_server_name: repository_name.git

Git_server_name indicates the machine name or IP address of the GIT server, and repository_name indicates the specified repository name.

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.