Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Private git building

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

The operating system used here is CentOS release 5.9 (Final), and Git and some necessary development tools are already installed.

Create a user and project repository (repository) on the server

Useradd git # create git user

Passwd git # set password

Su git # switch to git user

Cd ~ / # change to the home directory

Git init-- bare cube # create a project repository called cube

Clone project and submit changes (local)

Git clone git@IP address: cube ~ / cube

It is important to note that the password of the user git will be required here. We will not need to enter the password after we establish the host trust later.

Then create a README.txt under cube

Git add *

Git commit-m "create new file"

Git push origin master

Establish a host trust relationship

Execute locally

Ssh-keygen-t rsa

Cat / .ssh/id_rsa.pub

Copy the contents of the file public key

Execute on the server

Mkdir / .ssh

Chmod 755 ~. Ssh

Touch / .ssh/authorized_keys

Chmod 600 ~ / .ssh/authorized_keys

The public key of echo copy > ~ / .ssh/authorized_keys

Attention should be paid to the issue of file permissions.

Use gitosis to configure and manage the git server

Gitosis is a tool that provides access control and remote management for managed Git repositories. It allows fine-grained management of read and write access through SSH without requiring the user to have a local system account on the server. To do this, it sets up a single system account "git" and then uses it for all Git access.

Install the gitosis-git AUR package from AUR. This will create three things:

The git user

Git the group to which the user belongs

The / srv/gitosis directory will hold Gitosis's data and repositories

To configure Gitosis, you do not edit the file directly on the server. Instead, Gitosis provides a Git repository that contains configurations. To update this configuration, your gitosis-admin can be cloned, submitted, and pushed like any other repository.

Because Gitosis uses SSH keys to authenticate users, you will need to generate a key pair for managing the repository. If not, you can use ssh-keygen for example:

$ssh-keygen-t rsa

You can now initialize the management repository.

$sudo-H-u git gitosis-init

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report