Linux build git server

Source: Internet
Author: User
Tags git clone

Server-side configuration

1. Install git

2, create a new user, can only be used to upload code, but not through SSH login, such as git users

AddUser git

Chsh-s $ (command-v git-shell) git

Replace bash with Git-shell so that git users can't log in via SSH

This step will have a warning that Git-shell is not in the shell list, do not worry.

3, add the SSH public key, add the client's public key in/home/git/.ssh/authorized_keys, one line at a.

If there are no files, you can create a new

Mkdir/home/git/.ssh

Touch/home/git/.ssh/authorized_keys

The method by which the client generates the public key is Ssh-keygen,

Windows in the C:\Users\ user name \.ssh\ directory, open id_rsa.pub

4. Initialize an empty git repository

Cd/var

Git init--bare sample.git

Chown-r Git:git Sample.git

This step is to allow the directory to be modified by git users, or "Permission denied" error will occur.

Client

1, you can git clone

git clone [email protected] Server:/var/sample.git the file path on the server

or SSH, recommended ssh, easy to set the port number

git clone ssh://[email protected] Server: Port number/var/sample.git

Refer to Article 1, article 2

Linux build git server

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.