Install Git server on CentOS

Source: Internet
Author: User
Tags ssh port

Install Git server on CentOS

  1. View the Linux Server version
    # Cat/etc/redhat-release # view the system version
    CentOS release 6.5 (Final)

  2. Install git on the server

    • #sudo yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel perl-devel
    • #cd ~
    • #wget https://git-core.googlecode.com/files/git-1.9.0.tar.gzDownload the git-1.9.0.tar.gz installation package
      Other Versions
    • #tar -zxvf git-1.9.0.tar.gzExtract
    • #cd git-1.9.0
    • #make prefix=/usr/local/git all
    • #make prefix=/usr/local/git install
      Add soft connection
      • #ln -s /usr/local/git/bin/* /usr/bin/
    • #git --version
      How to display the version number is successful
  3. Install gitosis

    Note: gitosis is a Git user permission management system. It manages user permissions by managing the/home/git/. ssh/authorized_key file on the server. It is a python module package.

#yum install python python-setuptools
#git clone git://github.com/res0nat0r/gitosis.git
#cd gitosis/
#python setup.py install

If Finished processing dependencies for gitosis = 0.2 is displayed, the request is successful.

4.Modify the client's git connection port (if the GIT server uses the default SSH port 22, the following steps are not required)

Modify the configuration file of the client on the development machine (you can omit each input port) # vim ~ /. Ssh/config

After opening the file, edit the file and add the following code:

host www.domain.comhostname www.domain.comport 8200
** Use it later ** # after modification, the developer client can access it through the following methods: # git clone ssh: // git@www.domain.com/home/git/repositories/gitosis-admin.git # Otherwise you need to add a port for access # git clone ssh: // git@www.domain.com: 8200/home/git/repositories/gitosis-admin.git

5.On the Development Machine Client, generate the key and upload it to the server.# sh-keygen -t rsaPress enter without a password

Upload the generated public key from the development machine client to the server (if you modify the port, configure the specified port according to 4)# scp -P 8200 ~/.ssh/id_rsa.pub root@www.domain.com:/tmpShow uploaded keys# ls /tmp/id_rsa.pub

6.Generate git users on the server, use git users, and initialize gitosis

Add git users#adduser -m gitChange git User Password#sudo passwd gitSu to git user#su - gitGenerate a management database on the server (uploaded by the Development client just now)#gitosis-init < /tmp/id_rsa.pub

If the following information is displayed, the operation is successful.#Initialized empty Git repository in /home/git/repositories/gitosis-admin.git/ #Reinitialized existing Git repository in /home/git/repositories/gitosis-admin.git/

Delete key#su - root #rm -rf /tmp/id_rsa.pub

7.On the Development Machine Client, copy the git Management Project (git server management is also a git repository)

#mkdir -p /gitpo#cd /gitpo#git clone ssh://git@www.domain.com/home/git/repositories/gitosis-admin.git

8.Add and set management projects on the personal development Machine

Cd/gitpo/gitosis-admin # view the git server has uploaded the key ls keydir cat keydir/xx@xx.pub # xx@xx.pub for the Public Key generated by the uploaded developer # display the last string of the key as the key the username is xx @ xxvim gitosis. conf # Add the following content at the end of the file [group test-git] # Name of the group with write permission writable = test-git # Name of the group's writable project members = xx @ xx x2x2 @ x2x2 # members of this group (key user name) when multiple users collaborate in development, separated by spaces # If you want to add a read-only group, refer to the following # [group test-git-readnoly] # group names with full permissions # readonly = test-git # items read-only for this group name # members = xx @ xx # members of this group # submit and modify git add. git commit-a-m "add test-git repo" git push

9.Add and use the project test-git on the personal development machine.

#cd ~/gitpo #mkdir test-git #cd test-git #git init #touch readme #git add . #git commit -a -m "init test-git" #git remote add origin git@zgit:test-git.git #git push origin master 

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.