简体   繁体   English

向服务器上的git存储库添加身份验证层

[英]Adding a layer of authentication to git repositories on a server

I have my own private linux server. 我有自己的私人linux服务器。 I am using it to host all my company git repositories. 我正在使用它托管我公司的所有git存储库。 I am reading the .git directories using python . 我正在使用python阅读.git目录。 I also have a database that contain some information like the users who are allowed to login to the system. 我还有一个数据库,其中包含一些信息,例如允许用户登录到系统的用户。

The problem now, I have a linux user called git. 现在的问题是,我有一个名为git的Linux用户。 the user has all the repositories, and when I try to connect from an outside machine I have to upload the SSH keys to the server before pulling and pushing. 用户拥有所有存储库,当我尝试从外部计算机连接时,必须在拉动和推送之前将SSH密钥上载到服务器。

What I am trying to do now.. Is to create an authentication layer like github. 我现在正在尝试做的是创建一个像github这样的身份验证层。 Where the users can clone or push to private repositories by entering the username and password for the system. 用户可以通过输入系统的用户名和密码来克隆或推送到私有存储库。 Since the username and the password are in the database I need a python script OR any other script that will fetch the username and password. 由于用户名和密码在数据库中,因此我需要一个python脚本或将获取用户名和密码的任何其他脚本。

The question now, when a user tries to do this.. git push origin master for the first time. 现在的问题是,当用户首次尝试执行此操作时git push origin master and there were no SSH key. 而且没有SSH密钥。 I need something to say Please enter your username and password if the user is authenticated using the data in my database AND have access to this repository then I want him/her to be able to push the repo or clone it. 我需要说些什么,如果用户使用我数据库中的数据进行了身份验证并且可以访问此存储库, Please enter your username and password ,然后我希望他/她能够推送回购或克隆它。

Please don't mention ready software to host git repositories. 请不要提及现成的软件来托管git存储库。 This is not an option for me. 这不是我的选择。

Since you have ssh access, you can add an authorization layer like gitolite which will allow you to: 由于您具有ssh访问权限,因此可以添加诸如gitolite之类的授权层 ,这将使您能够:

That way, no need for a user database, and you can manage your entire user base and access rules from the gitolite-admin repo, a special administrative repo which will be interpreted on the server side by gitolite. 这样,无需用户数据库,您就可以从gitolite-admin库(一种特殊的管理存储库,将在服务器端由gitolite解释)管理整个用户群和访问规则。

See more at " How do programs like gitolite work? ". 请参阅“ 像gitolite的程序如何工作? ”中的更多内容。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM