Installing the GIT service on AWS ec2 ubuntu14.04

Source: Internet
Author: User
Tags git clone

http://imerc.xyz/2015/11/13/Ubuntu-14-04%E4%B8%8AGit%E6%9C%8D%E5%8A%A1%E5%99%A8%E7%9A%84%E6%90%AD%E5%BB%BA/

Tools and Platforms

Platform: Ubuntu Server 14.04

Tool: gitolite

Build Step 1, install Git and openssh-server

Assume that there is an administrator user named on the server System Ubunut admin , installed under the Admin user git andopenssh-server

install gitsudo apt-get install openssh-server
2. Create a git user

Create a user named Git to manage git:

shell 登录,shell是 /bin/bashsudo adduser --system --shell /bin/bash --group git 

Git is a name that can be changed, but is generally named Git.

Some systems only allow specific user groups (SSH user groups) to log on via the SSH protocol, so git users are added to the SSH user group:

sudo adduser git ssh

To set a password for a git user:

sudo passwd git
3. Generate SSH key under Admin user

or under Admin user, generate SSH key:

// 以 rsa 方式加密

If you do not want to change the default storage path, do not set the SSH communication password, as long as the return.
When this screen appears, the SSH key has been generated successfully.

The default SSH key is stored in the ~/.ssh folder, and we copy the public key id_rsa.pub into the git user's home directory and rename it as admin.pub :

sudo cp ~/.ssh/id_rsa.pub /home/git/admin.pub
4. Install gitolite under git user

To switch to a git user:

su git

Switch to the /tmp directory and clone the Gitolite source from GitHub:

cd /tmpgit clone https://github.com/sitaramc/gitolite.git

Create a new folder in the Git user's home directory bin , ready to install Gitolite:

cd ~mkdir bin

Install Gitolite:

/tmp/gitolite/install -to ~/bin

Use admin.pub to initialize the Gitolite initial warehouse:

~/bin/gitolite setup -pk ~/admin.pub

If the following information appears, the initialization is successful

The output information tells us that Gitolite helped us initialize two empty warehouses: gitolite.admin.git and testing.git . testing.gitIt's just a matter of creating a test for us, and gitolite.admin.git it's very important to manage it.
Because we use the Admin user's SSH key to initialize the Gitolite initial warehouse, so the admin user is the administrator, it can be used to increase the deletion of the warehouse, add users, permission management and so on.

To switch to the Admin user, try using SSH to login to the GIT user:

su adminssh [email protected]127.0.0.1

If the following information appears, the GIT server is basically well-built.

The above information indicates that the Admin user gitolite-admin currently testing has read and write permissions to and from the repository.
The SSH connection is turned off automatically, which is the role of gitolite, which prevents git users from using the shell to log in in case a git user does not have permission to corrupt the code repository.

Warehouse Management

Because the Admin user is the administrator of Gitolite, we can manage the warehouse under Admin user. Management is also done through Git clone/git push, and so on.

First gitolite-admin.git , clone the warehouse:

git clone git@127.0.0.1:gitolite-admin.git

As gitolite-admin you know, there are two folders under the folder conf and keydir . confThe warehouse configuration file is stored under the folder gitolite.conf . keydirthe SSH public key file for each user is stored inside.
Open gitolite.conf , the contents as shown, each repo represents a warehouse, the following indicates that a particular user has specific permissions. This can be used for permission control.

Suppose there are two users at this time Tom and Jack need to work with this GIT server to develop a project called Lake. First, Tom and Jack need to generate SSH keys on their respective computers, then rename the public key id_rsa.pub to Tom.pub and jack.pub, and add them to the directory under the Admin user on the server gitolite-admin/keydir/ .
The administrator then needs to edit the gitolite.conf file, create a new warehouse, and give Tom and Jack permission to read and write.

Now these configurations do not actually take effect, only the local (Admin user) to gitolite-admin the changes to the remote server (git users), the changes will take effect:

commit -m "create repo:Lake, add user:Tom&Jack"git push origin master

In this way, Tom and Jack have read and write access to the remote repository Lake and can collaborate on the development.

Installing the GIT service on AWS ec2 ubuntu14.04

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.