Build a git Linux server

Source: Internet
Author: User

Assuming you already have sudo access to the user account, below, formally start the installation.

First step, install git :

For Ubuntu or Debian

$ sudo apt-get install git

for Centos
更新一下 yum 源
yum list git 查看可安装版本
yum install git 安装

The second step is to create a git user to run the git service:

$ sudo adduser git

The third step is to create a certificate login:

Collect all the public keys of the users who need to log in, their own id_rsa.pub files, and import all the public keys into the /home/git/.ssh/authorized_keys file, one line at a.

The fourth step is to initialize the GIT repository:

First select a directory as the Git repository, assuming /srv/sample.git that the /srv command is entered in the directory:

$ 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 the user is not allowed to log on to the server directly to the workspace, and the Git repositories on the server usually .git end up. Then, replace the owner with the git following:

$ sudo chown -R git:git sample.git

Fifth step, disable the shell login:

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

This way, git users can use git normally via SSH, but cannot log in to the shell because we git git-shell automatically exit each time a login is specified for the user.

Sixth step, clone the remote repository:

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

$ git clone git@server:/srv/sample.gitCloning into ‘sample‘...warning: You appear to have cloned an empty repository.

The rest of the push is simple.

Build a git 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.