Build git code repository ssh protocol in CENTOS, centosgit

Source: Internet
Author: User
Tags centos server

Build git code repository ssh protocol in CENTOS, centosgit

Build git repository under centos server, use ssh protocol to manage repository code permission git official website (http://git-scm.com /)

Use ssh protocol:

1. install git, use yum install git or use the source code package to install git-2.2.0.tar.gz (https://www.kernel.org/pub/software/scm/git)

Create git users and user groups

# Useradd git
# Passwd git

2. Create a git repository (the repository location is determined by the user, for example,/var/git/testproject. git)

1. Create the project name testproject. git folder in the/var/git directory.

2, # cd/var/git/testproject. git enter the folder,

# Git init -- bare create a bare Library (note the -- bare parameter to generate a "clean" repository)

3. Modify permissions

# Chown-R git testproject. git
# Chgrp-R git testproject. git
# Chmod-R 775 testproject. git
# Chmod g + s-R testproject. git

3. Configure the ssh Public Key (no password is required to update the code library)

1. Generate the SSH public key:

Every software developer who needs to use the git repository needs to generate an ssh public key on a computer that uses the git repository. The specific steps are as follows:

1.1 enter your own ~ /. Ssh directory (the Windows system is in the user folder: C: \ Users \ Administrator \. ssh) to check whether the file name and file name are used. A pair of files named by pub. The file name is usually id_dsa or id_rsa.

* The pub file is the public key, and the other file is the key. If you do not have these files (or simply connect to them. no ssh directory). in linux, you can use the ssh-keygen program to create them. The program is provided by the SSH package on Linux/Mac systems; in Windows, ssh-keygen.exe is included in the MSysGit package, in the gitinstallation directory, and in binning.

After running, it requires you to confirm the location where the public key is saved (. ssh/id_rsa), and then it will let you repeat the password twice. If you do not want to enter the password when using the public key, leave it blank.

2. Copy the local *. add the content in pub to the/home/git /. run the command # $ cat/tmp/id_rsa.john.pub> ~ In the ssh/authorized_keys file ~ /. Ssh/authorized_keys: append the public key content to the authorization file.

If ~ /. Ssh/authorized_keys does not exist. You can directly copy the id_rsa.pub file and rename it to authorized_keys.

3. ssh Public Key authorization fails:

View and modify the ssh configuration file:

# Vi/etc/ssh/sshd_config

RSAAuthentication yes

PubkeyAuthentication yes

AuthorizedKeysFile. ssh/authorized_keys

After saving, service sshd restart takes effect

4. Use a repository

1. Open git bash on the authorized computer,

# Git clone git @ serverip:/var/git/testproject. git drop-down code without a password

 

Related Article

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.