Build git code Warehouse SSH protocol under CentOS

Source: Internet
Author: User
Tags centos server

Build a git repository under the CentOS server and use the SSH protocol to manage warehouse code permissions git official website (http://git-scm.com/)

Using the SSH protocol:

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

New git user and user group

# Useradd Git
# passwd git

Second, create a new git repository (warehouse location itself with the user's own decision, example/var/git/testproject.git)

1, create a new project name Testproject.git folder under the/var/git directory

2,# Cd/var/git/testproject.git into the folder,

# git init--bare to create a bare library (note the--bare parameter here, which means to generate a "clean" warehouse)

3, Modify Permissions

# chown-r git testproject.git
# chgrp-r git testproject.git
# Chmod-r 775 Testproject.git
# chmod G+s-r Testproject.git

Third, configure the SSH public key (no password update code base)

1, generate the SSH public key:

Every software developer who needs to use a git repository needs to generate an SSH public key on a computer that uses a git code base, in the following steps:

1.1 Enter your own ~/.SSH directory (win system in the User folder: C:\Users\Administrator\.ssh), to see if there is a file name and filename. pub to name a pair of files, this file name is usually ID_DSA or id_rsa.

The *.pub file is the public key, and the other file is the key. If there are no such files (or simply not even the. SSH directory), under Linux, you can use the Ssh-keygen program to build them, the program is provided by the SSH package in the Linux/mac system, and on Windows is included in the Msysgit package, the GIT installation directory In the bin path, under Ssh-keygen.exe.

After running, it asks you to confirm the location of the public key (. Ssh/id_rsa), then it will let you repeat a password two times, if you do not want to enter the password when using the public key, you can leave blank.

2, copy the contents of the *.pub to add to the GIT repository in the server's Git Users folder under the/home/git/.ssh/authorized_keys file can use the command # $ cat/tmp/id_rsa.john.pub > > ~/.ssh/authorized_keys, append the public key contents to the authorization file.

If ~/.ssh/authorized_keys does not exist, you can simply copy the id_rsa.pub file and rename it to Authorized_keys.

3, SSH uses the public key authorization does not pass the problem solves:

To 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

Iv. use of warehouses

1. On a licensed computer, open git bash,

# git clone [email protected]:/var/git/testproject.git can drop code without password

Build git code Warehouse SSH protocol under CentOS

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.