基于SSH的选择性访问Git存储库

编程入门 行业动态 更新时间:2024-10-12 20:28:48
本文介绍了基于SSH的选择性访问Git存储库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个拥有6个Git存储库的服务器,我已经通过一个SSH帐户读取并写入访问权限,所有都在/ opt / git /中,全部由SSH帐户拥有。

我想给其他人读取和写入访问一些存储库,但不是所有。

  • 如何创建一个只能访问少数选择存储库的新SSH用户?
  • 我可以使用文件权限(当前为0755)来控制此类访问吗?
  • 是否有最佳做法?

我们不太可能会有第三位开发人员在一段时间内,至少在我们没有得到正确的系统管理员之前,所以没关系,如果它现在足够好的话。

由 gitolite 管理授权层),这将允许您配置一个列表:

  • ssh用户密钥
  • 存储库

然后将您想要的用户关联到正确的回购站。

所有用户仍然可以通过ssh使用帐户git访问这些回购站,但使用他们自己的公钥/私钥SSH密钥(在gitolite配置文件中注册),使用类似于以下命令生成:

ssh-keygen -t rsa -f$ {H} /。ssh / myLogin-C我的Gitolite访问(不是交互式) - q -P

每个用户都会设置一个 %HOME%/ .ssh / config file 以引用 myLogin / myLogin.pub 键。

I have a server with six Git repositories, to which I have read+write access through a single SSH account, all in /opt/git/, all owned by the SSH account.

I'd like to give somebody else read+write access the a few of the repositories, but not to all.

  • How do I create a new SSH user that has access to only a few select repositories?
  • Can I use filepermissions (currently 0755) to control this type of access?
  • Are there any best practices?

It's unlikely we'll have a third developer for quite a while, atleast not before we get a proper sysadmin, so it's okay if it's "good enough for now".

解决方案

That would be best managed by gitolite (an authorization layer), which would allow you to configure a list of:

  • ssh user keys
  • repositories

And associate the users you want to the right repos.

All users would still access those repos through ssh with the account git, but using their own public/private ssh keys (registered in gitolite config file), generated with a command similar to:

ssh-keygen -t rsa -f "${H}/.ssh/myLogin" -C "My Gitolite access (not interactive)" -q -P ""

Each user would set up a %HOME%/.ssh/config file in order to reference myLogin/myLogin.pub keys.

更多推荐

基于SSH的选择性访问Git存储库

本文发布于:2023-10-27 10:45:41,感谢您对本站的认可!
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:选择性   SSH   Git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!