我可以为我的团队提供一个限制访问的 ssh linux 存储库的私钥吗?

Can I give my team a private key for an ssh linux repository that limits access?

我在学校有一个 linux 存储库,它允许我访问我自己的根目录。我可以给我的团队一个私钥,只允许他们 R/W 我自己目录中的某些文件夹吗?

例如,我会有两个这样的文件夹:path/to/folder1 & path/to/folder2。

我可以指定一个特定的私钥来只访问这两个文件夹吗?在任何其他文件夹中,尝试 R/W 将导致(访问被拒绝)。他们将以我的身份登录,但私钥将默认为此受限访问。

编辑:更好。我真正希望他们能够做的就是git merge main。而已。我希望它们能够在我的根目录中,并执行命令 git merge main。只有我希望他们拥有的访问权限。

是的。为此,您可以在 authorized_keys 文件中使用 command 参数。请参阅 https://man7.org/linux/man-pages/man8/sshd.8.html 中的 AUTHORIZED_KEYS 文件格式:

command="command"

Specifies that the command is executed whenever this key is used for authentication. The command supplied by the user (if any) is ignored. ... This option might be useful to restrict certain public keys to perform just a specific operation. An example might be a key that permits remote backups but nothing else.