`
orcl_zhang
  • 浏览: 242281 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

gitosis

    博客分类:
  • git
阅读更多
==========================================================
``gitosis`` -- software for hosting ``git`` repositories
==========================================================

Manage ``git`` repositories, provide access to them over SSH,
with tight access control and not needing shell accounts.

.. note::

Documentation is still lacking, and non-default configurations
(e.g. config file, repositories, installing in a location that
is not in ``PATH``) basically have not been tested at all.
Basic usage should be very reliable -- the project has been
hosting itself for a long time. Any help is welcome.

``gitosis`` aims to make hosting ``git`` repos easier and safer. It
manages multiple repositories under one user account, using SSH keys
to identify users. End users do not need shell accounts on the server,
they will talk to one shared account that will not let them run
arbitrary commands.

``gitosis`` is licensed under the GPL, see the file ``COPYING`` for
more information.

You can get ``gitosis`` via ``git`` by saying::

    git clone git://eagain.net/gitosis

And install it via::

    python setup.py install

Though you may want to use e.g. ``--prefix=``. For Debian/Ubuntu
users, the source is debianized.


Setting up
==========

First, we will create the user that will own the repositories. This is
usually called ``git``, but any name will work, and you can have more
than one per system if you really want to. The user does not need a
password, but does need a valid shell (otherwise, SSH will refuse to
work). Don't use an existing account unless you know what you're
doing.

I usually store ``git`` repositories in the subtree
``/srv/example.com/git`` (replace ``example.com`` with your own
domain). You may choose another location. Adjust to suit and run::

sudo adduser \
    --system \
    --shell /bin/sh \
    --gecos 'git version control' \
    --group \
    --disabled-password \
    --home /srv/example.com/git \
    git

This command is known to work in Debian and Ubuntu. Your mileage may
vary.

You will need an SSH public key to continue. If you don't have one,
you need to generate one. See the man page for ``ssh-keygen``, and you
may also be interested in ``ssh-agent``. Create it on your personal
computer, and protect the *private* key well -- that includes not
transferring it over the network.

Next, we need to set things up for this newly-created user. The
following command will create a ``~/repositories`` that will hold the
``git`` repositories, a ``~/.gitosis.conf`` that will be a symlink to
the actual configuration file, and it will add the SSH public key to
``~/.ssh/authorized_keys`` with a ``command=`` option that restricts
it to running ``gitosis-serve``. Run::

sudo -H -u git gitosis-init <FILENAME.pub
# (or just copy-paste the public key when prompted)

then just ``git clone git@SERVER:gitosis-admin.git``, and you get a
repository with SSH keys as ``keys/USER.pub`` and a ``gitosis.conf``
where you can configure who has access to what.

.. warning::

For now, ``gitosis`` uses the ``HOME`` environment variable to
locate where to write its files. If you use ``sudo -u``
without ``-H``, ``sudo`` will leave the old value of ``HOME``
in place, and this will cause trouble. There will be a
workaround for that later on, but for now, always remember to
use ``-H`` if you're sudoing to the account.

You should always edit the configuration file via ``git``. The file
symlinked to ``~/.gitosis.conf`` on the server will be overwritten
when pushing changes to the ``gitosis-admin.git`` repository.

Edit the settings as you wish, commit and push. That's pretty much it!
Once you push, ``gitosis`` will immediately make your changes take
effect on the server.


Managing it
===========

To add new users:

- add a ``keys/USER.pub`` file
- authorize them to read/write repositories as needed (or just
  authorize the group ``@all``)

To create new repositories, just authorize writing to them and
push. It's that simple! For example: let's assume your username is
``jdoe`` and you want to create a repository ``myproject``.
In your clone of ``gitosis-admin``, edit ``gitosis.conf`` and add::

[group myteam]
members = jdoe
writable = myproject

Commit that change and push. Then create the initial commit and push
it::

mkdir myproject
cd mypyroject
git init
git remote add myserver git@MYSERVER:myproject.git
# do some work, git add and commit files
git push myserver master:refs/heads/master

That's it. If you now add others to ``members``, they can use that
repository too.


Example configuration
=====================

.. include:: example.conf
   :literal:


Using git-daemon
================

Anonymous read-only access to ``git`` repositories is provided by
``git-daemon``, which is distributed as part of ``git``. But
``gitosis`` will still help you manage it: setting ``daemon = yes`` in
your ``gitosis.conf``, either globally in ``[gitosis]`` or
per-repository under ``[repo REPOSITORYNAME]``, makes ``gitosis``
create the ``git-daemon-export-ok`` files in those repository, thus
telling ``git-daemon`` that publishing those repositories is ok.

To actually run ``git-daemon`` in Ubuntu, put this in
``/etc/event.d/local-git-daemon``:

.. include:: etc-event.d-local-git-daemon
   :literal:

For other operating systems, use a similar invocation in an ``init.d``
script, ``/etc/inittab``, ``inetd.conf``, ``runit``, or something like
that (good luck).

Note that this short snippet is not a substitute for reading and
understanding the relevant documentation.


Using gitweb
============

``gitweb`` is a CGI script that lets one browse ``git`` repositories
on the web. It is most commonly used anonymously, but you could also
require authentication in your web server, before letting people use
it. ``gitosis`` can help here by generating a list of projects that
are publicly visible. Simply add a section ``[repo REPOSITORYNAME]``
to your ``gitosis.conf``, and allow publishing with ``gitweb = yes``
(or globally under ``[gitosis]``). You should also set ``description``
and ``owner`` for each repository.

Here's a LightTPD_ config file snippet showing how to run ``gitweb``
as a CGI:

.. _LightTPD: http://www.lighttpd.net/

.. include:: lighttpd-gitweb.conf
   :literal:

And a simple ``gitweb.conf`` file:

.. include:: gitweb.conf
   :literal:

Note that this short snippet is not a substitute for reading and
understanding the relevant documentation.



Contact
=======

You can email the author at ``tv@eagain.net``, or hop on
``irc.freenode.net`` channel ``#git`` and hope for the best.

There will be more, keep an eye on http://eagain.net/ and/or the git
mailing list.
分享到:
评论

相关推荐

    gitosis git服务器架设软件

    Gitosis则是方便通过Git与ssh架设中央服务器的软件。这篇文章的安装流程写得很明了,但使用中还是遇到了些许问题,本文算是该流程的补充。如果打算通过Gitosis架设服务器通过本文或许可以少走不少弯路。 一、架设...

    gitosis.tar.gz

    Gitosis 是一个基于 Git 的版本控制系统,用于管理多个用户的代码仓库。它允许用户通过 SSH 协议进行访问,实现权限控制和协作。本压缩包 "gitosis.tar.gz" 是一个用于在服务器上安装 Gitosis 的工具包,包含了必要...

    gitosis-master_20170112

    gitosis-master,有时github下载很慢,因此下载下来。更新到2017/01/12. Linux 下架设git服务器时使用。 git clone https://github.com/res0nat0r/gitosis.git

    gitosis打包文件

    Gitosis是一个旧版的Git仓库管理系统,用于帮助用户在服务器上管理和控制多个Git仓库的访问权限。它基于Python编写,提供了简单的权限管理机制,允许管理员通过Git仓库的SSH密钥来控制用户对仓库的读写权限。由于...

    gitosis install

    gitosis 安装详情 gitosis install

    Ubuntu下用Gitosis搭建GIT代码服务器及Eclipse下的Git操作

    Ubuntu下用Gitosis搭建GIT代码服务器及Eclipse下的Git操作

    gitosis 打包文件

    gitosis的打包文件,适合于无法联网从git获取clone的主机使用。在sles 11上安装成功;前提需要安装setuptools

    git-1.7.12.2 gitosis setuptools 软件

    这通常涉及解压gitosis-master.zip,将项目复制到适当的目录,编辑gitosis.conf文件来添加或删除用户,然后使用Gitosis的初始化脚本来设置仓库。Setuptools-0.6c8在这个过程中可能用于安装或更新Gitosis本身,或者在...

    在 Ubuntu 下搭建 git gitosis.docx

    在Ubuntu系统中搭建Git服务器,特别是使用gitosis作为版本控制系统管理工具,是一个常见的需求,尤其对于软件开发团队来说。Gitosis允许你集中管理和控制多个Git仓库,并为不同的用户或用户组设置权限。以下是一个...

    在 Ubuntu 下搭建 git gitosis.pdf

    在Ubuntu系统中搭建Git服务器,特别是使用gitosis作为版本控制系统管理工具,是一个常见的做法,尤其适合小型团队或个人开发者协作项目。以下将详细介绍这个过程。 首先,我们需要进行一些准备工作。在Mac上安装...

    gitosis2gitlab:从旧的 gitosis 遥控器到 gitlab 的代理

    但是现在,Gitosis 已经很多年没有维护了! 还有更好的方法来托管您自己的 git 存储库,例如 。 不幸的是,如果您已经使用 Gitosis 多年,那么您的 Gitosis 服务器参考周围可能有很多工作副本。 您可能还拥有希望 ...

    it's about gitosis

    关于git服务器配置哦过程中需要用到的gitosis文件,但是通过scp没法下载

    gitosis:管理git存储库,通过SSH提供对它们的访问,具有严格的访问控制,不需要shell帐户

    Gitosis是Git版本控制系统的一个管理工具,主要用于集中化管理和控制多个Git仓库,它通过SSH协议提供安全的访问,具备严格的访问权限控制。在不授予用户shell账户的情况下,Gitosis允许团队成员协作开发,确保代码的...

    GIT服务器配置

    5. 编辑Gitosis配置:Gitosis的配置文件位于gitosis.git/repo/etc/gitosis.conf。在这个文件中,你可以添加用户和仓库,设置读写权限。 6. 提交并推送配置:使用Git提交并推送配置更改。 ``` cd gitosis.git ...

    ubuntu 安装git 服务器.pdf

    本文主要介绍了 Git 服务器端安装及应用,包括安装 OpenSSH Server、配置 SSH 服务端、安装 Git、安装 Gitosis、创建系统用户和运行 Gitosis 等步骤。 一、安装 OpenSSH Server OpenSSH Server 是一个自由和开源的...

    Ubuntu下git服务器的搭建和基本使用[参考].pdf

    本文详细介绍了在Ubuntu系统下搭建和使用Git服务器的步骤,包括准备环境、安装ssh-server、安装git-core、安装gitosis、创建系统用户、运行gitosis、Git服务器管理员克隆仓库和修改gitosis.conf权限文档等方面的知识...

    ubuntu 安装git 服务器.docx

    本文主要介绍了在 Ubuntu 系统上安装和配置 Git 服务器的步骤,包括安装 OpenSSH Server、配置 SSH 服务端、安装 Git、安装 Gitosis、创建系统用户和运行 Gitosis 等内容。 一、安装 OpenSSH Server 为了确保 SSH ...

    linux下git安装使用[文].pdf

    在本文中,我们将详细介绍如何在 Linux 系统中安装和配置 Git 环境,包括设置用户权限、安装 Git、配置 Git 账号、初始化 Gitosis、配置 Git 服务选项等内容。 一、增加 yum repository 在 CentOS 中,要安装 Git ...

    git+repo+gerrit代码服务器搭建

    2. 安装 Gitosis:使用 `sudo python setup.py install` 安装 Gitosis。 3. 安装 Repo:使用 `sudo apt-get install repo` 安装 Repo。 创建 Gitosis 管理员 创建一个禁用密码的用户 git,並將其設置為 Gitosis 的...

Global site tag (gtag.js) - Google Analytics