CentOS 5.5 Git server and client Installation

Source: Internet
Author: User

CentOS 5.5 Git server and client Installation

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 ~] #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 .pub ssh -rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA6NwUHeNNi+PC6KlrcJrXXDmKxRMmgHIPp79sgX6zqfdSlmNj7rBPQeyEKS9Wg8yI6jd8aG2jsUx99Vjti2VK2vEXKkRHxwID7ri69gE71RfDtv6ekafnzLo14J8hAp0spMk+N3wEAQRYDmcYo1wmnm /jMBedGrHj4NJQ1vYy1hVtJasGMSzjcMrlz9qvaluWnQ5tQjKFQVVwKsRRRzs8qTvzVhLJt4NQ +CAN45tqfsRuf58Uba9QNK7 /6xSUiIKXQiILz8PMGJ3MnlV +eN3wx2aeztdevxu9plggtG05SMmd8GNVzXrN1IaxXSvz0UwjQ2kygu7aCqO8AZWH49rouw== 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 ~] # c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Ruf58Uba9QNK7 /6xSUiIKXQiILz8PMGJ3MnlV +eN3wx2aeztdevxu9plggtG05SMmd8GNVzXrN1IaxXSvz0UwjQ2kygu7aCqO8AZWH49rouw== 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] # git init --bare project.git [root@git project.git] # ls branches 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 git] # chown -R git.git project.git [root@git git] # ls -l Total 4 drwxr-xr-x 7 git git 4096 05-09 13:50 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 git git:x:1001:1001:git version control: /home/git : /bin/bash
Changed:
[root@git ~] # vim /etc/passwd git: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!

[root@ test ~] # yum install -y git

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

[root@ test ~] # git --version git version 1.8.2.

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

[root@ test ~] # ssh-keygen -t rsa Generating public /private rsa key pair. Enter file in which to save the key ( /root/ . ssh /id_rsa ): Created directory '/root/.ssh' . Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /root/ . ssh /id_rsa . Your public key has been saved in /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.pub ssh -rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwrmgNAca77BKzXl6BP11fdaclAoWfW+x4kPDZMPj1zFoML9JfOAS7DGY9quLMitwwfg5+U7zP /egPmAhSKCECubmodzMucnRSkJGgKCt1SlctRNDRN3OIvrecAtdZfDcBaWKLjaVzGPmhweLhr6HzfqeZU09Ccis4yK3RMwip2f +K1ZZVIOKUmL4AVFl9dqtxnQ4HlW61PUxvM /ug2M68Z0jQk5DVG8w5 +dvGqX1qr5YABD1NX5Jz6aUbVVx7yyoORENxu6SK83GI /V7eOkrvBMDh9nDdwvDhPhuhBDSfE +Xi92hPJPKdNroF1vx8HMvpHME20MmjSwavPrz+B18MQ== root@ test .com

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

[root@git ~] # su git bash -3.2$ cd bash -3.2$ vim . ssh /authorized_keys ssh -rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAwMU4FKB6NRc3XSoIunWsdvVVuSoncbVb5Al6lB3ciswBVd++YmJFhqwkITNGccrO5sycROs9+Fbjgd6oBSzNuaBtCIbwNNsEyM /henTl2euI3XsnJQ/ITr6c/q0P3WoGl4E2QFQ2kZqs +1eDC0CgHcBrqvFv1Jr414sVYK9lfZwIF+jDdtaBOrSJuq1Agx9pGUFUEB4tQfkXxsWm /MvOmKAVvduKDE1eenUEL9zzyeELPcSXLe3NOoTjZhkX6EEXxQR1ZiZRFywLpfM4qopZ10to2KIUyVtzw6hx6V3cg7kn40lYVW0EAMATw9dVldwcRUI +kJzJSKUTKDVSwY3/+Q== root@CHENMINGQIAN ssh -rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAsmmJuR+KhRSpdSirCiL30R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MvpHME20MmjSwavPrz+B18MQ== root@ test .com

Next we clone a repository to a local directory.

[root@ test ~] # cd /data/dev [root@ test dev] # git clone git@git.jjhh.com:/data/git/project.git Cloning 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 to continue connecting ( yes /no )? yes Warning: 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) Receiving objects: 100% (50 /50 ), 4.02 KiB, done . Resolving deltas: 100% (21 /21 ), done . [root@ test dev] # ls project [root@ test dev] # cd project/ [root@ test project] # ls index.html

Now, all the git clients have been installed here.

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.