Linux Git 服务器故障(Gitosis、Gitolite 等)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5607479/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-05 03:35:45  来源:igfitidea点击:

Git Server Frustration (Gitosis, Gitolite, etc)

linuxgitgitosisgitolite

提问by Benny

Please excuse the frustrating undertones as I have attempted to get this set up correctly multiple times to no avail (possibly and most likely due to my ignorance, but also likely due to the lack of thorough and concise documentation).

请原谅令人沮丧的暗示,因为我多次尝试正确设置此设置但无济于事(可能并且很可能是由于我的无知,但也可能是由于缺乏详尽而简洁的文档)。

I am trying to set up a git server so that I can share code amongst a small team of developers. Each developer may connect from multiple client PC's. I come from MS in the past so I am a bit spoiled in regards to development toolset, but it would be awesome if I could get something similar to TFS.

我正在尝试设置一个 git 服务器,以便我可以在一小群开发人员之间共享代码。每个开发人员可以从多个客户端 PC 连接。我过去来自 MS,所以我在开发工具集方面有点被宠坏了,但是如果我能得到类似于 TFS 的东西就太棒了。

When trying to set up either gitosis (I understand this is deprecated for the git community per https://serverfault.com/questions/225495/ubuntu-server-gitosis-user-naming-convention) or gitolite, it seems as though as soon as I set it up I have to be extremely careful because it seems everything is balancing on toothpicks.

当尝试设置 gitosis(我知道根据https://serverfault.com/questions/225495/ubuntu-server-gitosis-user-naming-convention不推荐使用 git 社区)或 gitolite 时,它​​似乎就像一旦我设置好它,我就必须非常小心,因为似乎一切都在牙签上保持平衡。

My latest attempt to set up a git server included moving my public key (benny.pub) from my laptop to the server, setting everything using that public key and pulling down the config to set up a repo and permissions. I then realized I want to develop on another PC so I created a new key ([email protected]) and renamed benny.pub to [email protected] which screwed things up obviously. This is where I know I was dumb by changing the name.

我最近尝试设置 git 服务器包括将我的公钥 (benny.pub) 从我的笔记本电脑移动到服务器,使用该公钥设置所有内容并拉下配置以设置 repo 和权限。然后我意识到我想在另一台 PC 上开发,所以我创建了一个新密钥 ([email protected]) 并将 benny.pub 重命名为 [email protected] 这显然把事情搞砸了。这就是我知道我通过更改名字很愚蠢的地方。

My question after a long-winded description is this: how can I set up a sturdy self-hosted git server with the ability to have multiple developers log in from multiple machines while maintaining security, etc? There has to be a proven technique (gitolite describes maybe 4-5 different ways...also frustrating) to do this as I'm sure I'm not the only one trying to do this exact same thing. Maybe git isn't right for my team?

经过冗长的描述后,我的问题是:如何设置一个坚固的自托管 git 服务器,使其能够让多个开发人员从多台机器登录,同时保持安全性等?必须有一种经过验证的技术(gitolite 描述了可能 4-5 种不同的方式......也令人沮丧)来做到这一点,因为我确信我不是唯一一个试图做完全相同的事情的人。也许 git 不适合我的团队?

Any help is greatly appreciated!

任何帮助是极大的赞赏!

采纳答案by Alexander Gro?

From my experience, all you need is a SSH server with a singlegit account/login that you are able to connect to using one of your public keys. Install gitolite using SSH (copies gitloite from your client to the server & does the basic setup) and have your developers send you their public keys. Add these keys to the gitolite-admin repository in your ~and push.

根据我的经验,您所需要的只是一个带有单个git 帐户/登录名的 SSH 服务器,您可以使用其中一个公钥连接到该服务器。使用 SSH 安装 gitolite(将 gitloite 从您的客户端复制到服务器并进行基本设置)并让您的开发人员向您发送他们的公钥。将这些密钥添加到您~并推送的 gitolite-admin 存储库中。

Why does a developer need more than one keypair in the first place, even if multiple machines are used? Such cases will neither influence how SSH handles authentication nor how gitolite handles authorization: they're still SSH keys.

即使使用多台机器,为什么开发人员首先需要多个密钥对?这种情况既不会影响 SSH 处理身份验证的方式,也不会影响 gitolite 处理授权的方式:它们仍然是 SSH 密钥。

  • If a developer has to use several keypairs (one for git, another for some other server), let them handle the complexity and advise them to create an entry in ~/.ssh/configfor each keypair/server combination they use.

  • If a developer has a different keypair on every machine used, gitolite groups can combine several public keys:

  • 如果开发人员必须使用多个密钥对(一个用于 git,另一个用于其他服务器),让他们处理复杂性并建议他们为~/.ssh/config他们使用的每个密钥对/服务器组合创建一个条目。

  • 如果开发人员在使用的每台机器上都有不同的密钥对,gitolite 组可以组合多个公钥:

@agross = agross-1 agross-2

回答by Ashwini Dhekane

i am using debian with every developer having an account on the server. i use ssh with private key login. Finally a developer has to use a url like ssh://[email protected]/git-repo/repo.git to checkout or in any case interact with git on repo

我正在使用 debian,每个开发人员在服务器上都有一个帐户。我使用带有私钥登录的 ssh。最后,开发人员必须使用像 ssh://[email protected]/git-repo/repo.git 这样的 url 来结帐或在任何情况下与 repo 上的 git 交互

回答by adl

I maintain a gitosis config at work, and when a developer has multiple ssh keys, all I have to do is put all these keys in the same keydir/user.pubfile.

我在工作中维护一个 gitosis 配置,当开发人员有多个 ssh 密钥时,我所要做的就是将所有这些密钥放在同一个keydir/user.pub文件中。

So concatenate all your keys into keydir/benny.puband you shoud be all set.

因此,将您所有的密钥连接起来keydir/benny.pub,您应该都已设置好。

回答by Rom1

A couple of pointers:

几个提示:

The section about git on the server on Scott Chacon's pro gitbook

Scott Chacon 的pro gitbook关于服务器上的git 的部分

Gitoriousis FOSS

Gitorious是 FOSS

回答by Jakub Nar?bski

There are a few open source git hosting solutions with a web-based UI for creating repositories and adding users (like GitHub:FI)... though I don't know about restricting access:

有一些开源 git 托管解决方案具有基于 Web 的 UI 用于创建存储库和添加用户(如GitHub:FI)...虽然我不知道限制访问:

HTH

HTH

回答by Rafael Diego Nicoletti

I think the problem is that you ssh client (windows or linux version) is not finding the key file. I had the same problem and solved this way:

我认为问题在于您的 ssh 客户端(windows 或 linux 版本)没有找到密钥文件。我遇到了同样的问题并以这种方式解决了:

  • In my notebook, generated the key file (rafael.nicoletti@mycorporation) in ~/.ssh folder (where ~ is home folder. windows version is %HOME% env)
  • I added a file name config in ~/.ssh with following content:

    IdentityFile ~/.ssh/rafael.nicoletti@corporation

  • 在我的笔记本中,在 ~/.ssh 文件夹中生成了密钥文件(rafael.nicoletti@mycorporation)(其中 ~ 是主文件夹。windows 版本是 %HOME% env)
  • 我在 ~/.ssh 中添加了一个文件名配置,内容如下:

    IdentityFile ~/.ssh/rafael.nicoletti@corporation

In every location i want to access my git servers, i just copy those files in my %HOME% folder

在我想访问我的 git 服务器的每个位置,我只需将这些文件复制到我的 %HOME% 文件夹中

You can also put the some things like this in config file:

你也可以把这样的东西放在配置文件中:

IdentityFile /d/identity.key
IdentityFile /e/identity.key
IdentityFile /f/identity.key
IdentityFile /.../identity.key

So the config will look for keys in removable medias.

因此,配置将在可移动媒体中查找密钥。