Git is built under Linux server

Source: Internet
Author: User
Tags git clone

This article takes CentOS as an example, other Linux please refer to the corresponding method.

1. Server-side Install git

Yum Install git

2. Add a user with no shell logon rights to the server and replace username with the user you want to add

Useradd-s/sbin/nologin username

3. Initializing the Warehouse

Git init--bare sample.git

4. In the client, that is, Gitbash (Windows user) generate the key and public key, the mailbox address to your own, of course, the following two-T and-C parameters can not.

Ssh-keygen " [email protected] "

Then to the user directory (the default), locate the. pub extension file under the. ssh folder, and the editor opens the copy

5. Open git permissions on the server and set the directory where the public key is saved

Access to SSH Setup path

vi /etc/ssh/sshd_config

Delete the comment # symbol below to save and exit

rsaauthentication Yes     Pubkeyauthentication Yes     authorizedkeysfile  . ssh/authorized_keys

From the code above you can see the path to save authorized key under/home/git/.ssh/authorized_keys

5. Add a public key file to the server-side git configuration file

Based on the key path obtained in the previous step, we entered/home/git and found that there is no. ssh folder, new folder. SSH, and go to the folder (the default LS command is not to show the Start folder), and then create a new file Authorized_keys, Save the public key obtained in step 4th to the file and exit. Then restart SSH

cd/home/git/mkdir . SSH CD. SSH VI authorized_keys# paste in fourth step copy of Gong # Save quit
Service sshd Restart #重启sshd

6. At this point, the client can submit or update the password via git clone.

git clone [email protected]:/path/to/rep.git

Git is built under Linux server

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.