Use gitosis to configure and manage git servers

Source: Internet
Author: User
Document directory
  • 1. Install git
  • 2. Install gitosis
  • 3. Generate a Public Key
  • 4. Upload the Public Key
  • 5. Generate a management database on the server
  • 6. Synchronize the configuration file
  • 7. Create a new repositories
Use gitosis to configure and manage git servers

Reprinted: http://blog.prosight.me/index.php/2009/07/271

1. Install git
  1.  
  2. Emerge-AV Dev-util/git
  3.  
2. Install gitosis

The GIT environment can be directly used by default, but you need to open an SSH permission account for each member, and cross-permission management between each warehouse is very troublesome, so you need to use gitosis, it does not require an SSH account for every developer, which is secure and convenient.

  1.  
  2. Emerge-AV gitosis
  3.  

If you are prompted that the package is mask, edit the/etc/portage/package. Keywords file and add

  1.  
  2. Dev-util/gitosis ~ Amd64
  3.  
3. Generate a Public Key

Use on the client

  1.  
  2. Ssh-keygen-T RSA
  3.  

To generate an SSH key. Note that your host name must contain all English characters and cannot contain special characters such as underlines or.. Otherwise, an error will be reported when the server generates a version library.

4. Upload the Public Key

Upload the generated public key from the client to the server.

  1.  
  2. SCP~ /.SSH/Id_rsa.pub user @ your_server:/tmp
  3.  
5. Generate a management database on the server
  1.  
  2. Sudo-H-u git gitosis-init </tmp/id_rsa.pub
  3.  

If it succeeds, you will see a message similar to the following:

  1.  
  2. Initialized empty git repository in/var/spool/gitosis/repositories/gitosis-admin.git/
  3. Reinitialized existing git repository in/var/spool/gitosis/repositories/gitosis-admin.git/
  4.  

Set post-update script Permissions

  1.  
  2. Chmod755/var/spool/gitosis/repositories/gitosis-admin.git/hooks/post-Update
  3.  

Now, the server configuration has been completed.

6. Synchronize the configuration file

Gitosis itself is a git library, so it is very convenient to manage. The following figure shows how to synchronize the gitosis management library on the client.

  1.  
  2. Git clone git @ your_server: gitosis-admin.git
  3. CD gitosis-Admin
  4.  

You will see the following files

  1.  
  2. -RW-r-1 Garry 104 Nov 13 gitosis. conf
  3. Drwxr-XR-x 3 Garry 102 Nov 13 keydir/
  4.  

Gitosis. conf is the configuration file of gitosis for configuring users and permissions.
Keydir/is the public key of all group members
We can modify the configuration locally and change the permission. After the permission is pushed to the server, the server takes effect immediately.

7. Create a new repositories

Open the gitosis. conf file and you will see

  1.  
  2. [Group gitosis-admin]
  3. Writable = gitosis-Admin
  4. Members = Elton @ MacBook
  5.  

This is the Management Group permission. The username in members is the username in the uploaded public key.
Add the following content to the file:

  1.  
  2. [Group myteam]
  3. Members = Elton @ MacBook
  4. Writable = free_monkey
  5.  

Here you define a group named myteam and grant the repo permission to the Elton @ MacBook user to write "free_monkey ".

  1.  
  2. Git commit-a-m "allow Elton write access to free_monkey"
  3. Git push
  4.  

The above operation updates the server's permissions.
Create a repo for free_monkey.

  1.  
  2. MkdirFree_monkey
  3. CD free_monkey
  4. Git init
  5.  

Create a. gitignore file to ignore some content that does not require code management. For example, the rails application may be as follows:

  1.  
  2. . Ds_store
  3. Log/*. Log
  4. TMP /**/*
  5. Config/database. yml
  6. DB/*. sqlite3
  7.  

Code submission:

  1.  
  2. Git remote add origin git @ your_server_hostname: free_monkey.git
  3. Git add.
  4. Git commit-a-m "Initial import"
  5.  
  6. Git push origin master: refs/heads/Master
  7.  

Next, you can add the Member's public key to the system.

  1.  
  2. CD gitosis-Admin
  3. CP~ /Alice. Pub keydir/
  4. CP~ /Bob. Pub keydir/
  5. Git add keydir/Alice. Pub keydir/Bob. Pub
  6.  

Modify gitosis. conf

  1.  
  2. [Group myteam]
  3. -Members = jdoe
  4. + Members = jdoe Alice Bob
  5. Writable = free_monkey
  6.  

Submit changes:

  1.  
  2. Git commit-a-m "granted Alice and Bob commit rights to freemonkey"
  3. Git push
  4.  

Other members can get the code.

  1.  
  2. Git clone git @ your_server: free_monkey.git
  3.  

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.