Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Lets say I boot up my computer and I see the login screen. When I log in as myuser, I want to be restricted to a certain root directory via. chroot.

Let's assume that the directory is /chroots/myuser/. Is this possible to do ? If so, how would it be accomplished ?

Note:
Just to be clear, I want to change the root directory, not the home directory. The new root directory for the user will contain another OS like Debian.

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

Change the user's default shell in /etc/passwd to the command (or a wrapper script for that command) that logs that user into the chroot.

share|improve this answer
2  
I think maybe you will then want a separate /etc/password inside the chroot which lists bash, see eg. here: olivier.sessink.nl/jailkit/howtos_ssh_only.html –  goldilocks Jan 14 '13 at 12:58
2  
@goldilocks I use schroot which has a -s flag, with which you can set the shell for the user that you log in as. It also updates the user in /etc/passwd to use that shell (in the chroot environment). –  user1973386 Jan 14 '13 at 16:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.