git 配置gitosis_使用Gitosis在Git服务器上管理存储库

git 配置gitosis

How to manage users and repositories and how to use these repositories will be introduced in this post. Please refer to Setting Up a Git Server Using Gitosis for how to set up the git server. Please refer to Howto for New Git Users for how to use git as a new user.

本文将介绍如何管理用户和存储库以及如何使用这些存储库。 请参阅“使用Gitosis设置Git服务器”以了解如何设置git 服务器 。 有关如何将git用作新用户的信息,请参考How to for New Git Users

创建一个新用户 (Create a new user )

Now let’s see how to create a new user user1.

现在,让我们看看如何创建一个新用户user1。

First the new user user1 generates his/her public SSH key and copies or emails the public part of its SSH key to the administrator (we copy to /tmp/user1.pub in this example):

首先,新用户user1生成其公共SSH密钥,并将其SSH密钥的公共部分复制或通过电子邮件发送给管理员(在此示例中,我们复制到/tmp/user1.pub):

$ ssh-keygen -t rsa
$ cp ~/.ssh/id_rsa.pub /tmp/user1.pub

Then the administrator copies use1‘s public SSH key to the keydir directory in the gitosis-admin repository on the administrator’s local machine:

然后,管理员将use1的公用SSH密钥复制到管理员本地计算机上的gitosis-admin存储库中的keydir目录中:

$ cp /tmp/user1.pub keydir/

Add to the gitosis-admin repository

添加到gitosis-admin存储库

$ git add keydir/user1.pub

Commit the changes

提交更改

$ git commit -a -m 'user user1 is added'

Push to the git server

推送到git服务器

$ git push

After this administrator pushing the new commit, user1 has been added to gitosis on the git server. The name of the user’s public SSH key file is in this format:

该管理员推送新提交后,已将user1添加到git服务器上的gitosis中。 用户的公共SSH密钥文件的名称采用以下格式:

user1.pub

user1.pub

Please note that the name of the file should be the same as the user name. For example, the public key file for user1 should be user1.pub .

请注意,文件名应与用户名相同。 例如,user1的公钥文件应为user1.pub。

在配置文件∞中创建新的存储库记录 (Create a new repository record in configuration file )

All the operations in this part is done by administrator on it’s local machine.

此部分中的所有操作均由管理员在本地计算机上完成。

We add a new repository named gitosis-test. In the configuration file, we add a new group gitosis-test-group and we add user1 to it’s members list. This group can write to gitosis-test repository, so that user1 can write to this repository. As described before, add these lines to gitosis.conf file:

我们添加了一个名为gitosis-test的新存储库。 在配置文件中,我们添加一个新组gitosis-test-group,并将user1添加到其成员列表中。 该组可以写入gitosis-test存储库,以便user1可以写入此存储库。 如前所述,将这些行添加到gitosis.conf文件中:

[group gitosis-test-group]
writable = gitosis-test
members = user1

We can also grant readonly access to this repository to a group of users as follows:

我们还可以向一组用户授予对此存储库的只读访问权限,如下所示:

[group gitosis-test-readonly-group]
readonly = gitosis-test
members = readuser1 readuser2

Then commit and push the changes to the server:

然后提交并将更改推送到服务器:

$ git commit -a -m 'config for new repository gitosis-test is added'
$ git push

By now, the new repository record has been added in the configuration file. User user1 is granted write privilege to it. If we want to add another user such as user2 to gitosis-test-group, just make this change:

至此,新的存储库记录已添加到配置文件中。 用户user1被授予写权限。 如果我们要将另一个用户(例如user2)添加到gitosis-test-group,只需进行以下更改:

- members = user1
+ members = user1 user2

Create and use the repository

创建和使用存储库

The user1 can create the repository by itself following the introduction in Howto for New Git Users.

用户1可以按照Howto for New Git Users中的介绍自行创建存储库。

翻译自: https://www.systutorials.com/managing-repositories-on-git-server-using-gitosis/

git 配置gitosis

Git是非常著名的分布式版本控制系统。 Gitosis则是方便通过Gitssh架设中央服务器的软件。这篇文章的安装流程写得很明了,但使用中还是遇到了些许问题,本文算是该流程的补充。如果打算通过Gitosis架设服务器通过本文或许可以少走不少弯路。 一、架设步骤 1. 下载并安装python setuptools sudo apt-get install python-setuptools 2. 下载并安装gitosis cd ~/src git clone git://eagain.net/gitosis.git cd gitosis python setup.py install 3. 添加用户git sudo adduser \ --system \ --shell /bin/sh \ --gecos 'git version control' \ --group \ --disabled-password \ --home /home/git \ git 4. 生成本机密钥 切换到个人机,如果已有~/.ssh/id_rsa.pub略过此步 ssh-keygen -t rsa 5. 上传密钥到服务器临时目录 scp ~/.ssh/id_rsa.pub 用户名@主机:/tmp 6. 初使化gitosis 切回到服务器 sudo -H -u git gitosis-init < /tmp/id_rsa.pub 7. 修改post-update权限 sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-update 8. clone gitosis管理平台 git clone git@主机名:gitosis-admin.git cd gitosis-admin 9. 安装完成 通过修改gitosis-admin管理gitosis用户权限 添加公密到keydir,添加用户 修改完后commit,push到中服务器即可完成仓库权限的相关操作。 二、实例 目标:添加用户 john 和仓库 foo 到gitosis,并和管理员miao合作管理 1. 用户john添加并发送id_rsa.pub给miao john:~$ ssh-keygen -t rsa Generating public/private rsa key pair. Enter file in which to save the key (/home/john/.ssh/id_rsa): Created directory '/home/john/.ssh'. Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/john/.ssh/id_rsa. Your public key has been saved in /home/john/.ssh/id_rsa.pub. john:~$ cp /home/john/.ssh/id_rsa.pub /tmp
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值