CentOS 6.5 GIT Server Setup

Source: Internet
Author: User

CentOS git Server Setup


1. Environment deployment


System environment:

Server side: CentOS 6.5 ip:192.168.0.74


2. Installation

2.1 Server side:

Yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel


Vi/etc/yum.repos.d/epel.repo

-----------------------------------------------------------------------------------------------------

[Epel]

Name=extra Packages for Enterprise Linux 6-$basearch

#baseurl =http://download.fedoraproject.org/pub/epel/6/$basearch

Mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-6&arch= $basearch

Failovermethod=priority

Enabled=1

Gpgcheck=1

Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-epel


[Epel-debuginfo]

Name=extra Packages for Enterprise Linux 6-$basearch-debug

#baseurl =http://download.fedoraproject.org/pub/epel/6/$basearch/debug

Mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-debug-6&arch= $basearch

Failovermethod=priority

Enabled=0

Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-epel

Gpgcheck=1


[Epel-source]

Name=extra Packages for Enterprise Linux 6-$basearch-source

#baseurl =http://download.fedoraproject.org/pub/epel/6/srpms

Mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-source-6&arch= $basearch

Failovermethod=priority

Enabled=0

Gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-epel

Gpgcheck=1


-----------------------------------------------------------------------------------------------------


Yum-y Install git Git-daemon


View version number: Git--version





3. Installing Gitosis

Gitosis is a GIT user Rights management system that manages user rights by managing/opt/git/.ssh/authorized_key files on the server side.

Yum Install Python Python-setuptools

git clone git://github.com/res0nat0r/gitosis.git

CD gitosis/

Python setup.py Install

(Finished processing dependencies for gitosis==0.2 means installation complete)


3.1 Create a personal public key and private key (for administrator management of the following GIT services)

SSH-KEYGEN-T RSA



3.2 Creating a GIT server administrative user

Useradd-m git

passwd git



3.3 Creating a git repository storage directory

Mkdir/opt/git



3.4 Setting git repository permissions

Chown Git:git/opt/git

chmod 755/opt/git/




3.5 Initializing Global Settings

git config--global user.name "Zhu.zhihuan"

git config--global user.email "[Email protected]"



3.6 Configuring Gitosis

CP ~/.ssh/id_rsa.pub/tmp

Sudo-h-u git gitosis-init </tmp/id_rsa.pub//import the public key into Gitosis, this machine has git admin rights

chmod 755/home/git/repositories/gitosis-admin.git/hooks/post-update

Cat/tmp/id_rsa.pub >>/home/git/.ssh/authorized_keys//Import the root's public key into the Git directory

chmod 600/home/git/.ssh/authorized_keys




3.7 Managing Gitosis Configuration

git clone [email protected]:/gitosis-admin.git (hostname for native)

Receiving objects:100% (5/5), done (login successful)

CD gitosis-admin/(gitosis.conf is a git repository and permissions file, Keydir directory is the public key directory for other clients)





4. Add-other users (Linux)

Upload the other user's own public key to the GIT server


Store the user's public key in the/root/gitosis-admin/keydir directory




4.1 Importing the user's public key into the Git directory (home/git)

Cat/root/gitosis-admin/keydir/jicki.pub >>/home/git/.ssh/authorized_keys




4.2 Edit gitosis.conf File


----------------------------------------------------------------------

[Gitosis]

[Group Gitosis-admin]

writable = Gitosis-admin

Members = [email protected]

#加一个名为 groups of Yumwei

[Group Yumwei]

Members = Jicki #这里的jicki对上面公匙文件名

writable = Yumwei #项目仓库名


------------------------------------------------------------------------


4.3 Submit to Repository

Git add/root/gitosis-admin/keydir/jicki.pub

Git commit-a-M "Allow Jicki Write access to Yunwei"

Git push Origin Master



At this time Jicki will have permission to operate Yunwei Warehouse, back to the user machine


CD ~

Mkdir/opt/yunwei

Cd/opt/yunwei

echo "Test" > Test.txt

GIT init//Initialize local version

git remote add origin [email protected]:yunwei.git//Add to remote repository

git Add.

Git commit-a-M "hahaha, test it"

Git push Origin Master



[Test has been submitted to the server library] clone back in other directory

Cd/tmp

git clone [email protected]:yunwei.git


CentOS 6.5 GIT Server Setup

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.