Is there someway to restrict su to a specific group of users?
Upon searching over the web, I came across IBM AIX's concept of sugroup. Whenever a user is created, attribute sugroup can be set; and only members of this group are allowed to su to that user.
sugroup can help me solve my problem by creating a group which contains only certain users allowed to su. Assigning sugroup means users outside this group are not permitted to be su-ed to by other users. But this concept of sugroup is not available in Ubuntu. How can it be achieved in Ubuntu?
I made following entry in /etc/pam.d/su:
auth required pam_wheel.so group=sulogin
I created following:
- a group called
suloginwhich is for users allowed to su - users who don't belong to
suloginareuser1anduser2 - users who do belong to
suloginareadmin1andadmin2
Now when I am logged in as user1 and try to su to admin1 or admin2, I am not permitted to do so. This is as per my requirement. When I am logged in as user1 and try to su to user2, I am not permitted to do this. This is not as per my requirement (although my requirements were not clearly mentioned in the original question).
I need to restrict all the users who are not in group sulogin from su-ing to any user who belongs to sulogin group. Basically, 2 levels of su privilege. So in the above mentioned scenario:
user1should be able tosutouser2and vice-versauser1oruser2should not be able tosutoadmin1oradmin2admin1should be able tosutouser1oruser2