How to create a confined user in Ubuntu?

Posted by BagCompetitive357@reddit | sysadmin | View on Reddit | 18 comments

I have a question that looks like basic to system administration, but surprisingly I cannot find information about that.

I have a multi user system. I want to make sure that a particular user has access only to a set of resources like a set of applications.

Traditional Unix DAC permissions don’t seem to provide a simple solution to role-based access control. It seems MAC using SeLinux or AppArmor is required.

RHEL/Fedora have SeLinux with targeted policy which comes with labels for users, like, guest_u label for the context of a predefined confined user. I can create a new user and label it with guest_u. This way the user will be confined to capabilities defined by guest_u. It’s hard to cherry pick and compile new modules (guest is more like a kiosk), but at least there is something.

But I have Debian/Ubuntu. To my surprise, I found it difficult to create a user that is confined in Ubuntu. I can remove the user from the sudo group and prevent the user from running certain commands like su. That’s all.

I want to define a user that has access to certain folders and can run certain applications (like a browser, vscode, editors, other basic utilities) and nothing more. How could this be done?

The closest that I found was installing and configuring an obscure module called AppArmor PAM module. I might be wrong but there might be just one example in the internet on this module and almost none in Reddit. It’s not well documented.

There ought to be an easy way to confine a user in Ubuntu.