This whole deal with jails and chroot is a bit confusing to me. They are used to run possibly risky programs securely, but this has to be initiated by the user. I'm looking for how to jail users like how Android and iOS do it. This can be setup for remote logins, but how can this be set for home logins?
Assume that I have Ubuntu installed on a desktop PC. There are four users: administrator, user1, user2, and guest. The first logs in like an account normally does. The second and third login to a jail. The fourth logs into a more restrictive jail than the second and third. Do these jailed accounts have access to a virtualized environment of sorts? Do these include copies of core binaries or are they built into the all's interface? Are these accomplished with initialization scripts or something else?
Chroot jail setup
Create user to be jailed.
For setting chroot we need to set sudo privilage to the users.
Add the user in sudo group
Create folder to setup a user in jail
The jail user can access only whatever inside the /chroot folder
This means we need to provide something in there,unless the user only can see empty folder
Just create basic necessary things
We want to copy the software to /chroot that the jail user can able to use
Bash command
ls command
Copy this lib file to chroot lib directory
su command
Add some system configuration files and additional libraries to the chroot
Copy nsswitch.conf file to /chroot
Inside the nsswitch it should looks like the follow
We copy the configuration files necessary for the PAM system to operate so that the authorization in the jail can work
We add some additional libraries required by the PAM and the name service switch facilities
We need to create login.defs file in /chroot/etc/ directory.This file defines some setting for the login process
Add the following line in to the login.defs file
If we did not do this the su command would attempt to use the syslog utility,which is not available in the jail setup and the entire process would fail.
Create the script that will put our user in jail,whenever he login in to the system
Create file jailshell in /bin directory,outside the jail
Add the following script in to that file
Make it executable
To put script in action,we need to edit the /etc/passwd file (which is outside of the jail).
Change /bin/bash to /bin/jailshell in user acer
Set user acer in jail's home directory
The following could also be useful
Everything done.Now test the login