将 su 限制为一组用户

Man*_*ish 6 su

有没有办法限制su特定的用户组?

在网上搜索时,我遇到了 IBM AIX 的sugroup. 每当创建用户时,sugroup都可以设置属性;并且只有该组的成员才被允许对该用户进行 su。

sugroup可以通过创建一个仅包含允许 su 的某些用户的组来帮助我解决我的问题。分配sugroup意味着该组之外的用户不允许被其他用户起诉。但是这个概念sugroup在 Ubuntu 中不可用。如何在 Ubuntu 中实现?

我在以下条目中输入/etc/pam.d/su

auth required pam_wheel.so group=sulogin

我创建了以下内容:

  • 一个名为的组sulogin,供允许 su 的用户使用
  • 不属于的用户suloginuser1user2
  • 属于的用户suloginadmin1admin2

现在,当我以 as 登录user1并尝试 su 到admin1or 时admin2,我不允许这样做。这是按照我的要求。当我以身份登录user1并尝试 su 时user2,我不允许这样做。这不符合我的要求(尽管原始问题中没有明确提到我的要求)。

我需要限制所有不在组中的sulogin用户起诉属于sulogin组的任何用户。基本上是 2 个级别的 su 权限。所以在上面提到的场景中:

  • user1应该能suuser2,反之亦然
  • user1或者user2不应该能够suadmin1admin2
  • admin1应该能够suuser1user2

mur*_*uru 6

在 Ubuntu 上可以使用等效项,只是默认情况下未启用。退房/etc/pam.d/su

# Uncomment this to force users to be a member of group root
# before they can use `su'. You can also add "group=foo"
# to the end of this line if you want to use a group other
# than the default "root" (but this may have side effect of
# denying "root" user, unless she's a member of "foo" or explicitly
# permitted earlier by e.g. "sufficient pam_rootok.so").
# (Replaces the `SU_WHEEL_ONLY' option from login.defs)
# auth       required   pam_wheel.so
Run Code Online (Sandbox Code Playgroud)

因此,取消注释此auth行,su则将仅限于 group 的成员root。或者取消注释并添加group=sulogin,如果您想限制为sulogin组。