Git server construction and Client installation in CentOS

Source: Internet
Author: User

Outline:

I. Preface

2. Build a Git Server

  • Install the Git server in yum

  • Create a git user to run the git Service

  • Create a client logon Certificate

  • Initialize Git Repository

  • Disable shell Logon

  • Clone remote Repository

3. Install the client

  • Windows Client

  • Linux Client

Iv. Summary

Note: CentOS 5.5 x86_64, Git server version: git version 1.8.2.1, and Client version: git version 1.9.2.msysgit.0. Download all the software here: http://msysgit.github.io /.

I. Preface

In the previous blog, we mainly explained what Git is, the basic principles of Git, and some basic knowledge about Git, so that we can briefly understand Git, of course we still have a lot of questions to figure out, hey! Don't manage. We have to have a Git server before we can figure out these problems, right? Hey hey! Now let's build a Git server together.

2. Build a Git Server

1. Install the Git server in yum

[Root @ git ~] # Cd src/[root @ git src] # wget unzip src] # rpm-ivh epel-release-5-4.noarch.rpmPreparing... ######################################## ### [100%] package epel-release-5-4.noarch is already installed [root @ git ~] # Yum list [root @ git ~] # Yum install-y git

2. Create a git user to run the git Service

[Root @ git ~] # Adduser git

3. Create a client logon Certificate

Note: Collect the public keys of all users that need to log on, that is, the id_rsa.pub file generated by them, copy all the public keys to the/home/git/. ssh/authorized_keys file, one row at a time. Hey!

1). The client generates the id_rsa.pub FILE command

$ Ssh-keygen-t rsa $ cat. ssh/id_rsa.pubssh-rsa secure + N3wEAQRYDmcYo1wmnm/secure + can45tsecure sruf58uba9nkq7/secure + secure = leo @ LEO-PC

Note: Press enter all the way to copy the generated id_rsa.pub to the Administrator and add it to the server. You do not need to enter the user name and password the next time you use git.

2) view the authorized_keys file on the server

[Root @ git ~] # Cat/home/git /. ssh/authorized_keysssh-rsa keys ++ keys + keys/henTl2euI3XsnJQ/ITr6c/keys + keys/+ Q = root @ CHENMINGQIANssh-rsa keys + bwiJ2iQRa39rXck35r + keys // RiCiYzd3RT/cores + S/LD3vx2MN + FNOHwvqcE + cores/RZ54Q = Administrator @ WIN2003X323ssh-rsa cores + N3wEAQRYDmcYo1wmnm/cores + cores = leo @ LEO-PC

Note: I have three users logging on to the server, so I have three ssh-rsa users. You can check them out.

4. initialize the Git Repository

Note: select a directory as the Git repository. Here is/data/git/project. git.

[Root @ git ~] # Cd/data/git/[root @ git] # git init -- bare project. git [root @ git project. git] # lsbranches config description HEAD hooks index info objects refs

Execute the above command Git command to create a bare repository. The bare repository does not have a work zone. Because the Git repository on the server is purely for sharing, users are not allowed to log on to the server directly to change the work zone, and the Git repository on the server usually uses. git end. Then, change the owner to git:

[Root @ git] # chown-R git. git project. git [root @ git] # ls-l total 4drwxr-xr-x 7 git 4096 05-09 project. git

5. Disable shell Logon

Note: For security reasons, the git user created in step 2 cannot log on to the shell, which can be completed by editing the/etc/passwd file. Find a line similar to the following:

[Root @ git ~] # Cat/etc/passwd | grep gitgit: x: 1001: 1001: git version control:/home/git:/bin/bash
Changed:
[Root @ git ~] # Vim/etc/passwdgit: x: 1001: 1001: git version control:/home/git:/usr/bin/git-shell

In this way, git users can normally use git through ssh, but cannot log on to the shell, because the git-shell that we specify for git users will automatically exit upon every login.

6. clone a remote Repository

Note: Now you can clone the remote repository using the git clone command and run the following command on your computer:

 

Note, $ git clone git@git.jjhh.com:/data/git/project. git, where git username, git.jjhh.com server,/data/git/prgject. git is the repository path. Now, the server is set up here. Next, we will install the client.

3. Install the client

1. Windows Client

1) download the client

Note: Download http://msysgit.github.io /. The following is a simple demonstration of the installation process:




Now the installation is complete. After the installation is complete, an icon will be displayed on the desktop. You can double-click it. For example:

2. Linux Client

Note: The installation of the Linux client is relatively simple, just install it with yum!

1 [root @ test ~] # Yum install-y git

Git installation is complete. Let's check the version below:

12 [root @ test ~] # Git -- versiongit version 1.8.2.

Next we generate a public key and copy it to the server:

[Root @ test ~] # Ssh-keygen-t rsaGenerating public/privatersa key pair. enterfileinwhichto save the key (/root /. ssh/id_rsa): Created directory '/root /. ssh '. enter passphrase (emptyforno passphrase): Enter same passphrase again: Your identification has been savedin/root /. ssh/id_rsa.Your public key has been savedin/root /. ssh/id_rsa.pub.The key fingerprint is: 48: 3c: 22: 76: 02: f1: a2: e5: 27: 22: cb: 4f: a7: a0: 98: 9d root@test.com [ Root @ test ~] # Cat. ssh/id_rsa.pubssh-rsa keys + U7zP/keys + keys/ug2M68Z0jQk5DVG8w5 + keys/V7eOkrvBMDh9nDdwvDhPhuhBDSfE + keys + B18MQ = root@test.com

Next, copy the public key in id_rsa.pub to the authorized_keys file on the server.

[Root @ git ~] # Su gitbash-3.2 $ cdbash-3.2 $ vim. ssh/authorized_keysssh-rsa keys ++ keys + keys/henTl2euI3XsnJQ/ITr6c/keys + keys/+ Q = root @ CHENMINGQIANssh-rsa keys + bwiJ2iQRa39rXck35r + keys // RiCiYzd3RT/cores + S/LD3vx2MN + FNOHwvqcE + cores/RZ54Q = Administrator @ WIN2003X323ssh-rsa cores + N3wEAQRYDmcYo1wmnm/cores + cores = leo @ LEO-PCssh-rsa keys + U7zP/keys + keys/ug2M68Z0jQk5DVG8w5 + keys/V7eOkrvBMDh9nDdwvDhPhuhBDSfE + keys + B18MQ = root@test.com

Next we clone a repository to a local directory.

[Root @ test ~] # Cd/data/dev [root @ testdev] # git clone git@git.jjhh.com:/data/git/project. gitCloning into 'project '... the authenticity of host 'git .jjhh.com (114.112.173.150) 'can't be established. RSA key fingerprint is ca: ec: a2: 7e: e6: 89: ca: 19: d3: 93: 7f: 4b: c3: c0: c7: fd. are you sure you want tocontinueconnecting (yes/no )? YesWarning: Permanently added 'git .jjhh.com, 114.112.173.150 '(RSA) to the list of known hosts. remote: Counting objects: 50, done. remote: Compressing objects: 100% (42/42), done. remote: Total 50 (delta 21), reused 0 (delta 0) Grouping ing objects: 100% (50/50), 4.02 KiB, done. resolving deltas: 100% (21/21), done. [root @ testdev] # lsproject [root @ testdev] # cd project/[root @ testproject] # lsindex.html

Now, all the git clients have been installed here.

Iv. Summary

Q & A: Are you welcome to discuss any issues. Finally, I hope you will have some gains ......

This article is from "Share your knowledge ..." Blog, please be sure to keep this source http://freeloda.blog.51cto.com/2033581/1410562

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.