Build a git server under Linux

Source: Internet
Author: User

1. Install git

Yum Install Curl-devel expat-devel gettext-devel OpenSSL-devel zlib-devel Perl-devel

Yum Install git

2. Next we create a git user group and a user to run the GIT service:

Groupadd git

AddUser git -g git

3. Import our public key into the/home/git/.ssh/authorized_keys file, one line at a.

If you do not have the file to create it:

$ cd /home/git/

$ mkdir . SSH

$ chmod . SSH

< Span class= "PLN" >< Span class= "PLN" >$ touch . Ssh/authorized_keys

$ chmod . SSH/authorized_keys

3. Initialize the GIT repository

First we select a directory as the Git repository, assuming/home/gitrepo/runoob.git, enter the command in the/home/gitrepo directory

$ cd /home

$ mkdir Gitrepo

$ chown git:git gitrepo/

$ CD Gitrepo

$ git init -bare runoob. git

< Span class= "PLN" > Initialized empty git repository in /home/gitrepo /runoob.

Change the repository owner to git:

Chown -R git:git runoob. git

4. Testing

git clone [email protected]:/home/gitrepo/runoob. git

5. For security reasons

Git server opens RSA authentication
You can then add your public key to the GIT server to verify your information. On a git server, you first need to turn on RSA authentication in/etc/ssh/sshd_config, which is:

1.RSAAuthentication yes     2.PubkeyAuthentication yes     3.AuthorizedKeysFile  .ssh/authorized_keys

Disable the git user's 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  

After the last colon, change to:

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



Build a git server under Linux

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.