Page 1

Sjoerd's user-chroot-HOWTO 29-10-2001


This HOWTO shortly explains how one can chroot a user during login. This means that after the user has logged in, he is restricted to a certain directory. This directory is his new root directory. See the chroot manual for more details about chroot.


You have to configure two options:

  • /etc/passwd
  • setting up a chroot directory

Configuring /etc/passwd

The important thing is the star at the end. This indicates that after login, a chroot is done to the user's directory (here /pub/ftp) and another login session is started.

Note: Two login sessions are started, and the user has to give his password twice if you don't do anything about it.

Setting up the chroot directory

Links are green, dirs are blue.

  • bin/bash
  • bin/login
  • dev/
  • etc/group
  • etc/pam.conf
  • etc/pam.d/
  • etc/passwd
  • etc/shadow
  • lib/
  • lib/
  • lib/
  • lib/
  • lib/
  • lib/
  • lib/
  • lib/
  • lib/

You need a login and a shell: /bin/bash and /bin/login. These programs need libraries. You can find out which libraries by executing

. Login does also need the pam configuration files and some files in the dev directory. My dev dir contains
and the result of
/dev/MAKEDEV console
(login reported that it couldn't find my tty).
The links in the lib dir are the same as where I coppied them from.

One can test his rootdir by executing:

  • chroot . /bin/bash
  • chroot . /bin/login
Where . is de directory you want to use for your chroot.