来自 Windows 的 git Push 验证将作者设置为未知
我最近在 Ubuntu 服务器上的私人网络中设置了一个新的 gitosis。网络中的所有其他客户端都是 Windows XP 计算机,除了一个 Linux 客户端之外,
我在 gitosis.conf 中进行了以下设置:
[group MyProjectTeam]
writable = MyProjectRepo
members = user1 user2 user3
我还在 keydir 中放置了 user1.pub、user2.pub 和 user3.pub 密钥文件。密钥是使用 ssh-keygen 在 Ubuntu 服务器上生成的,并分发给各个用户。公钥的副本放置在 keydir 中。
前两名用户是 Windows XP 用户,他们使用 msysgit + TortoiseGit 来处理存储库,一名用户在 Linux 计算机上使用默认的 git 命令行版本来访问存储库。
现在一切都设置好了,每个人都能够做他们期望做的任何事情,他们能够拉、推、提交 - 一切看起来都很好,除了我们检查日志时!
在 Linux 机器上使用 user3,我尝试了“git log”命令并得到以下输出:
commit 1b249e239d270b814aab31eed7dc6f04ceceba32
Author: User3 <Admin@ubuntu-server.(none)>
Date: Fri Sep 11 07:26:58 2009 +0530
modifed by user3
commit 646f8b11a715273dc26280fc1da2507c997f981c
Author: unknown <Admin@.(none)>
Date: Fri Sep 11 07:10:56 2009 +0530
modified by user2
commit 9f86dc7a6bfafc1c1e520d6de3dac7c613ac85cb
Author: unknown <Admin@.(none)>
Date: Fri Sep 11 06:50:22 2009 +0530
modified
commit b1a3b64005795f9592aae05c422c70a03dbb9b58
Author: admin <Admin@ubuntu-server.(none)>
Date: Fri Sep 11 06:18:54 2009 +0530
test file added by admin
这是不正确的。这个日志应该可以告诉我Push的作者是谁。我的感觉是,它为 Linux 上的用户提供了正确的值,因为他们的用户名和电子邮件也被添加到 Linux 用户信息中,但对于 Windows 客户端来说,情况并非如此,因此他们的名称无法正确显示。但即使我在 Windows 计算机上修复名称,这也可能会因模拟其他用户名而受到损害,为避免这种情况,我不想依赖用户名。
我希望 SSH 文件中提供的名称出现在那里,或者在推送时使用的 SSH 文件的名称被添加为作者。
可能 git 的钩子预接收可以在这里提供帮助,但我不知道如何使用它......任何人都可以帮忙吗?
谢谢, Rakesh
更新:
感谢您的回答。
alexandrul,我没有设置全局设置,这是因为我希望每个用户的信息都应该被真实记录。
Squelch,你是对的,我可以看到省略用户名的用户,但我如何强制他们这样做。我可以告诉他们配置本地项目并设置用户名和电子邮件地址,但是如果有人使用假用户名或尝试使用其他人的用户名和电子邮件地址(基本上是试图冒充其他人)怎么办?
这就是为什么我想为什么不记录私钥文件的名称,例如我将用户1的文件名设置为user1.ppk,类似地,将用户2的文件名设置为user2.ppk。在这种情况下,即使有人试图冒充其他人,他们也不会成功,因为用于检查的键名会告诉我真相。
有什么想法吗???
问候, Rakesh
更新2:
感谢您的帮助。 Squelch,感谢您花时间解释这么多细节。我认为电视的蜘蛛网有很多信息,现在就读。
到目前为止,我所做的一件事是:要求我的用户更新他们的配置以包括用户名和电子邮件地址。但我必须解决这个问题,因为我无法追逐每个用户。
我想要像 SVN+SSH 这样的东西,我们在密钥文件中使用经过加密的用户名,并用 SVN 记录它。
I have recently setup a new gitosis in my private network on Ubuntu server. All other clients in network are Windows XP machine except one Linux client
I have following setup in gitosis.conf:
[group MyProjectTeam]
writable = MyProjectRepo
members = user1 user2 user3
I have also placed user1.pub, user2.pub and user3.pub key files in keydir. The keys were generated on Ubuntu server using ssh-keygen and distributed to respective users. Copy of public keys are placed in keydir.
First two users are Windows XP users they use msysgit + TortoiseGit to work with repository and one user is on Linux machine to access the repository using default command line version of git.
Now all is setup well and everybody is able to do whatever they are expected to, they are able to pull, push, commit - everything looks fine except when we check logs!!!
Using user3 on Linux machine, I tried "git log" command and got following output:
commit 1b249e239d270b814aab31eed7dc6f04ceceba32
Author: User3 <Admin@ubuntu-server.(none)>
Date: Fri Sep 11 07:26:58 2009 +0530
modifed by user3
commit 646f8b11a715273dc26280fc1da2507c997f981c
Author: unknown <Admin@.(none)>
Date: Fri Sep 11 07:10:56 2009 +0530
modified by user2
commit 9f86dc7a6bfafc1c1e520d6de3dac7c613ac85cb
Author: unknown <Admin@.(none)>
Date: Fri Sep 11 06:50:22 2009 +0530
modified
commit b1a3b64005795f9592aae05c422c70a03dbb9b58
Author: admin <Admin@ubuntu-server.(none)>
Date: Fri Sep 11 06:18:54 2009 +0530
test file added by admin
This is not correct. This log should be able to tell me who is the Author of Push. What I feel is that its giving correct values for users on Linux as their user name and emails are also added in the Linux user info but for windows clients its not true so their names does not appear correctly. But even if I fix names on Windows machine, this can be compromised by emulating other users name, to avoid this I don't want to rely on user names.
I want name provided in SSH file be appear there or name of the SSH file that was used while push to be added as Author.
May be git's hook pre-receive can help here but I don't know how to use it... can anybody help?
Thanks,
Rakesh
UPDATE:
Thanks for answers.
alexandrul, I have not set the global settings this is because I want every user's information should be logged genuinely.
Squelch, you are correct I can see the users who are omitting their user names but how do I enforce them to do so. I can tell them to config their local project project and set username and email address but what if some one uses fake username or tries to use someone else username and email address, basically tries to personate other?
That's why I thought why not to log the name of private key file, e.g. I have set file name as user1.ppk for user1 similarly user2.ppk for user2. in such cases even if someone tries to personate other they wont succeed cause key names that are used for checking will tell me the truth.
any ideas???
Regards,
Rakesh
UPDATE 2:
Thanks for help. Squelch, thanks for taking time to explain in so much of details. I think that TV's cobweb has lot of info, reading it right now.
As of now one thing I have done is: asked my users to use update their config to include username and email address. But I got to solve the problem as I can not chase each and user.
I want something like SVN+SSH where we use tunnled username in key file and it gets recorded with SVN.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您是否尝试使用以下命令设置用户名:
或
编辑:全局设置存储在HOME环境变量指定的文件夹中,该文件夹对于每个Windows用户来说应该是唯一的,因此您将拥有有关登录用户的真实数据。
Did you try to set the user name with the following commands:
or
Edit: global settings are stored in the folder designated by the HOME environment variables, which should be unique for each Windows user, so you will have real data about the logged in user.
进一步扩展 alexandrul 的 amswers,当用户访问存储库时,会发生多个进程。
正如您所发现的,gitosis 只能验证用户是否有权连接,并且他们只能访问他们所属的存储库。它不会检查提交中的有效名称,并且一个用户完全有可能在存储库中模拟另一个用户(只要他们有权访问)。
您的用户不会滥用系统,这是您隐含的信任问题,毕竟您已经允许他们访问存储库。如果您怀疑有不当行为,日志将揭示在进行特定推送时连接了哪个 ssh 身份验证的用户。
我不确定 gitosis 是否公开了连接的 SSH 用户的名称,因此可以对提交消息进行简单的交叉检查,但我希望有才华的 Pythonista 可能能够提出一些建议。或者,向 gitosis 的作者 Tommi Virtanen 提出功能请求。
电视蜘蛛网
Expanding further on alexandrul's amswers, There are several processes going on when a user accesses the repository.
As you have discovered, gitosis can only authenticate that a user has a right to connect, and that they have access to only those repositories they are a member of. It does not check for a valid name within the commit, and it is entirely possible for one user to impersonate another within a repository as long as they have access.
It is a matter of implicit trust on your part that your users do not abuse the system, you have already allowed them access to the repository after all. The logs would uncover which ssh authenticated user was connected when a particular push was made if you suspect wrongdoings.
I am not sure if gitosis exposes the name of the connected SSH user so a simple cross check can be made against the commit message, but I expect a talented Pythonista may be able to suggest something. Alternately, make a feature request with Tommi Virtanen the author of gitosis.
TV's cobweb
问题出在您的 Windows 用户身上。如果您要求他们向您提供在项目文件夹中运行时的输出
,您可能会发现他们省略了设置用户名和电子邮件。
让他们再次在项目文件夹中运行 alexandrul 建议的命令,因为如果不绕过 gitosis 的设计目的(即在没有 shell 帐户的情况下提供安全的 git 访问),您在服务器端实际上无能为力。
如果您将来可能有其他 Windows 用户,可以使用检查有效用户名和电子邮件的预接收挂钩来避免这种情况。它所需要做的就是拒绝推送并显示一条消息,让用户先进行设置。
请参阅上一个问题寻求帮助关于最后一点。
The problem lies with your Windows users. If you ask them to supply you with the output from
when run within the project folder, you will probably see that they have omitted to set their user names and email.
Ask them to run the commands alexandrul suggests, again within the project folder, as there is not really much you can do on the server end without circumventing what gitosis is designed to do ie provide secure git access without shell accounts.
If you are likely to have other windows users in future, a pre-receive hook that checks for a valid user name and email could be used to avoid this. All it needs to do is reject the push with a message for the user to make the settings first.
See Previous SO question for help on this last point.