How to run a command in a chroot jail not as root and without sudo?

后端 未结 5 523
北海茫月
北海茫月 2020-12-07 22:56

I\'m setting up a minimal chroot and want to avoid having sudo or su in it but still run my processes as non-root. This is a bit of a trick as running chroot requiers root.

5条回答
  •  余生分开走
    2020-12-07 23:58

    You could use Linux Containers to create a chroot environment that is in a totally different namespace (IPC, filesytem, and even network)

    There is even LXD which is able to manage the creation of image-based containers and configure them to run as unprivileged users so that if the untrusted code manages to somehow escape the container, it will only be able to execute code as the unprivileged user and not as the system's root.

    Search 'Linux Containers' and 'LXD' on your favorite search engine ;)

提交回复
热议问题