Linux CentOS git Build

Source: Internet
Author: User
Tags free ssh git clone

1. Install git

sudo yum install Git

2. Querying the GIT version

Git–version

Installation is successful if displayed

3. Create a git user to run the GIT service

AddUser git

4. Go to the directory and initialize the GIT repository

sudo git init--bare sample.git

Git creates a bare repository with no workspaces, because the GIT repository on the server is purely for sharing, so you don't let users log on to the server directly to the workspace, and the Git repositories on the server usually end up with. Git. Then, change owner to git:

Chown-r Git:git Sample.git

5. Configure password-free SSH login

On gitclient_01, we use the command: ssh-keygen–t RSA to generate the key, as

After completion, in the. SSH directory, we can see the Id_rsa and id_rsa.pub files, id_rsa.pub as the public key, we scp/home/git/.ssh/id_rsa.pub gitserver:/home/by command Git copies the public key generated on the gitclient_01 to the Gitserver.

On Gitserver We first look at whether Authorized_kesys files exist under the/home/git/.ssh directory,

If not, you can create this file and folder from Touch Authorized_keys.

After the Authorized_keys is created, append the contents of the public key id_rsa.pub copied on the gitclient_01 to the Authroized_keys, note that it is appended to the file, and you can use the command cat/home/git/id_ Rsa.pub>>/home/git/.ssh/authorized_keys.

When the above content is complete, we can use the command SSH gitserver to complete the login without password in gitclient_01.

6. Disable Shell logon:

For security reasons, the GIT user created in the second step is not allowed to log in to the shell, which can be done by editing the/etc/passwd file. Find a line similar to the following:

git:x:1001:1001:,,,:/home/git:/bin/bash

Switch

git:x:1001:1001:,,,:/home/git:/usr/bin/git-shell

7. Cloning a remote repository:

Now, you can clone the remote repository with the git clone command and run it on your own computer:

$ git clone [email protected]:/srv/sample.git

Enter Password login

Cloning into ' sample ' ...

Warning:you appear to has cloned an empty repository.

Linux CentOS git Build

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.