「Git サーバー」の版間の差分

提供: ArchWiki
ナビゲーションに移動 検索に移動
(→‎SSH: 一部飜訳)
(→‎SSH: 飜訳)
22行目: 22行目:
 
この SSH ユーザーアカウントでは、push と pull のコマンドのみを許可することで、より安全性を確保することができます。これは、デフォルトのログインシェルを git-shell に置き換えることで実現します。[https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server Setting Up the Server] で説明しています。
 
この SSH ユーザーアカウントでは、push と pull のコマンドのみを許可することで、より安全性を確保することができます。これは、デフォルトのログインシェルを git-shell に置き換えることで実現します。[https://git-scm.com/book/en/v2/Git-on-the-Server-Setting-Up-the-Server Setting Up the Server] で説明しています。
   
  +
[[#全般]]の手順で作成した git サーバーをこの条項の手順 ([[#SSH]]) で保護する場合、Arch では以下の追加手順が必要です。
When securing the git server created using the instructions in [[#General]] with the instructions of this clause ([[#SSH]]), the following additional steps are needed on Arch:
 
   
;correct home directory: In order for ssh to be able to read /srv/git/.ssh/authorized_keys, the home directory for git in /etc/passwd needs to be changed from "/" to "/srv/git".
+
;正しいホームディレクトリ: ssh /srv/git/.ssh/authorized_keys を読めるようにするには、/etc/passwd git 用ホームディレクトリを "/" から "/srv/git" に変更する必要があります。
  +
;ホームディレクトリが修正された場合のベースパスの修正: gitがリポジトリを提供するために、gitのホームディレクトリからリポジトリを提供する場合、"/usr/lib/systemd/system/git-daemon@.service" の --base-path を "/srv/git" へ変更する必要があります。
;correct base path when home directory is corrected: In order for git to serve the repositories, the --base-path in "/usr/lib/systemd/system/git-daemon\@.service" need to be changed to "/srv/git" if the repositories are served from git's home directory.
 
   
 
=== Smart HTTP ===
 
=== Smart HTTP ===

2022年1月27日 (木) 21:20時点における版

この記事では、Git サーバーをホストする方法について概要を説明します。より詳細な情報は、Pro Git book の Git on the Server chapter の章を参照ください。

プロトコル

詳細な説明と長所・短所は、Git on the Server - The Protocols を参照してください。

全般

Step by Step Guide on Setting Up git Server では Arch での安全でないサーバーのセットアップを説明しています。

デフォルトでは、git ユーザは期限切れになっています("Your account has expired; please contact your system administrator")。有効期限切れの条件を解除するには、例えば、以下のように chage を使用します。

chage -E -1 git

SSH

SSH サーバーを設置するだけです。

この SSH ユーザーアカウントでは、push と pull のコマンドのみを許可することで、より安全性を確保することができます。これは、デフォルトのログインシェルを git-shell に置き換えることで実現します。Setting Up the Server で説明しています。

#全般の手順で作成した git サーバーをこの条項の手順 (#SSH) で保護する場合、Arch では以下の追加手順が必要です。

正しいホームディレクトリ
ssh が /srv/git/.ssh/authorized_keys を読めるようにするには、/etc/passwd の git 用ホームディレクトリを "/" から "/srv/git" に変更する必要があります。
ホームディレクトリが修正された場合のベースパスの修正
gitがリポジトリを提供するために、gitのホームディレクトリからリポジトリを提供する場合、"/usr/lib/systemd/system/git-daemon@.service" の --base-path を "/srv/git" へ変更する必要があります。

Smart HTTP

この記事またはセクションは加筆を必要としています。
理由: There are many web servers with CGI support. (議論: トーク:Git サーバー#)

The git-http-backend(1) is a CGI program, allowing efficient cloning, pulling and pushing over HTTP(S).

Apache

The setup for this is rather simple as all you need to have installed is the Apache HTTP Server, with mod_cgi, mod_alias, and mod_env enabled) and of course, git.

Once you have your basic setup running, add the following to your Apache configuration file, which is usually located at:

/etc/httpd/conf/httpd.conf
<Directory "/usr/lib/git-core">
    Require all granted
</Directory>
 
SetEnv GIT_PROJECT_ROOT /srv/git
SetEnv GIT_HTTP_EXPORT_ALL
ScriptAlias /git/ /usr/lib/git-core/git-http-backend/

This assumes your Git repositories are located at /srv/git and that you want to access them via something like: http(s)://your_address.tld/git/your_repo.git.

ノート: Make sure that Apache can read and write to your repositories.

For more detailed documentation, visit the following links:

Git

The Git protocol is not encrypted or authenticated, and only allows read access.

The Git daemon (git-daemon(1)) can be started with git-daemon.socket.

The service uses the --export-all and --base-path parameters to serve all repositories placed in /srv/git/.

Access control

For fine-grained access control, the following solutions are available:

  • Gitolite — An access control layer on top of Git, written in Perl.
https://github.com/sitaramc/gitolite || gitolite
  • Gitosis — Software for hosting Git repositories, written in Python.
https://github.com/tv42/gitosis || gitosis-gitAUR

Note that if you are willing to create user accounts for all of the people that should have access to the repositories and do not need access control at the level of git objects (like branches), you can also use standard file permissions for access control.[1]

Web interfaces

Simple web applications

  • Gitweb — the default web interface that comes with Git
  • cgit — A web interface for git written in plain C.
https://git.zx2c4.com/cgit/ || cgit

Advanced web applications

  • Gitea — Painless self-hosted Git service. Community managed fork of Gogs.
https://gitea.io || gitea
  • GitLab — Project management and code hosting application, written in Ruby.
https://gitlab.com/gitlab-org/gitlab-ce || gitlab
  • Gogs — Self Hosted Git Service, written in Go.
https://gogs.io || gogsAUR