Git Install remote service setup under Linux

Source: Internet
Author: User
Tags git clone



System environment:

    • CentOS 6.6 x86_64
    • Service-Side ip:192.168.2.45

This article builds a remote service for the SSH protocol of Git. With the creation of a normal user, through the SSH protocol authorized access to the operation of the idea is exactly the same, but the server and the client in the operation of the project with Git only, the service is very simple to build. Of course more and more detailed configuration is to look at the git manual.

Install Git
# yum Install git
Add git user

User name can be random, I create a git-named user here:

# AddUser git

Disable git user login, modify/etc/passwd file, will:

git : x : 501 : 501 :: /home/ git : /bin/ Bash

Switch

git : x : 501 : 501 :: /home/ git : /usr/ bin / git - Shell

If you are creating a different user name, modify the login method for the app username to/usr/bin/git-shell.


Git SSH Key Generation steps

One

Set the user name and email for git:

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


Second, the process of generating SSH key:
1. See if you already have an SSH key: CD ~/.ssh
If there is no key then there will be no such folder, there is a backup to delete
2. Survival key:

$ ssh-keygen-t rsa-c "[Email protected]"
Press 3 to enter, the password is empty.


Your identification has been saved In/home/tekkub/.ssh/id_rsa.
Your public key has been saved in/home/tekkub/.ssh/id_rsa.pub.
The key fingerprint is:
..................


Finally, two files were obtained: Id_rsa and Id_rsa.pub




Authorized access

Password-free access : Collects the client's Id_rsa.pub public key, appended to/home/git/.ssh/authorized_keys:

# cat/path/to/some_client/id_rsa.pub >>/home/git/.ssh/authorized_keys

If the client has root privileges or has write access to the/home/git directory, it can be used:

# SSH [email protected] ' mkdir-p/home/git/.ssh && cat >>/home/git/.ssh/authorized_keys ' < ~/.ssh/id_rs A.pub

Access with password :

# passwd git  Enter the password you want to set

If you are creating a different user name, modify the password for the app name.

Create a Git project

Suppose we put the GIT project in the/opt/gitproj directory uniformly:

# mkdir-p/opt/gitproj

To create a project:

# cd/opt/gitproj/# git init--bare sample.git

Modify Permissions:

# chown-r Git:git Sample.git

We'll first clone a copy locally, and later, when the client submits the file, it can pull validation here:

# cd/tmp/# git clone/opt/gitproj/sample.git/Initializedgit   in/tmp/sample/.   git / Warning :   you appear to has cloned an empty repository.

If you have only one server, git services and Web services are all on top, then you might consider choosing this approach.

Verify

Client :

$ git clone [email protected].168.2. $:/opt/gitproj/Sample.gitCloning  into ' Sample '...Warning:  Youappear to has cloned an empty repository. CheckingConnectivity...  Done.$ cd Sample/$ echo' first commit ' > 1.txt$ git add1.txt$ git commit-am' Update '$ git pushCountingObjects: 3,  Done. WritingObjects:  -% (3/3),  -bytes| 0bytes/s,  Done.  Total 3 (Delta0),reused0 (Delta0)  to[email protected].168.2. $:/opt/gitproj/Sample.git* [NewBranch]Master -Master

If a fatal:the remote end hung up unexpectedly error occurs, use Git push origin master to push.

Go to service side :

Now let's go to the/tmp/sample/directory to pull up the latest submitted file and verify:

# cd/tmp/sample/ # git pullRemote: CountingObjects: 3,  Done.Remote:  Total 3 (Delta0),reused0 (Delta0) UnpackingObjects:  -% (3/3),  Done.  from /opt/gitproj/Sample* [NewBranch]Master -Origin/Master# cat 1.txtFirst commit

This is where our git service is built, very simple.

Reference
http : //www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000/ 00137583770360579bc4b458f044ce7afed3df579123eca000  http://git-scm.com/book/zh/v1/ The-git-protocol on the server http://git-scm.com/book/zh/v1/Server on the-git- server http:  //www.ruanyifeng.com/blog/2011/12/ssh_remote_login.html
Reprint please indicate the source.  This article address:http://blog.aboutc.net/linux/71/ Git-remote-services-to-build-under-linux



Git Install remote service setup 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.