What you're essentially doing is creating a skeleton root file system with enough components necessary, binaries, password files, etc. to allow Unix to do a chroot when the user logs in. Note that if you use the
--enable-ls option during compilation as seen above, the /home/ftp/bin, and /home/ftp/lib directories are not required since this new
option allows Wu-ftpd to use its own ls function. We still continue to demonstrate the old method for people that prefer to copy /bin/ls to the chroot'd FTP
directory, /home/ftp/bin and create the appropriated library related to ls.

The following are the necessary steps to run Wu-ftpd software in a chroot jail:
First create all the necessary chrooted environment directories as shown below:
[root@deep ] /# mkdir /home/ftp/dev
[root@deep ] /# mkdir /home/ftp/etc
[root@deep ] /# mkdir /home/ftp/bin
[root@deep ] /# mkdir /home/ftp/lib
Require only if you are not using the | |
Require only if you are not using the |
Change the new directories permission to 0511 for security reasons:
The chmod command will make our chrooted dev, etc, bin, and lib directories
readable and executable by the super-user root and executable by the user-group and all users.
[root@deep ] /# chmod 0511 /home/ftp/dev/
[root@deep ] /# chmod 0511 /home/ftp/etc/
[root@deep ] /# chmod 0511 /home/ftp/bin
[root@deep ] /# chmod 0511 /home/ftp/lib
Require only if you are not using the | |
Require only if you are not using the |
Copy the
/bin/lsbinary to/home/ftp/bindirectory and change the permission of thelsprogram to0111. You don't want users to be able to modify the binaries:[root@deep ] /# cp /bin/ls /home/ftp/bin
[root@deep ] /# chmod 0111 /bin/ls /home/ftp/bin/ls
Require only if you are not using the
--enable-lsoption.Require only if you are not using the
--enable-lsoption.This step is necessary only if you're not using the
--enable-lsoption during the configure time of Wu-ftpd. See the Compile and Optimize section in this chapter for more information.Find the shared library dependencies of the
lsLinux binary program:[root@deep ] /# ldd /bin/ls
libc.so.6 => /lib/libc.so.6 (0x00125000) /lib/ld-linux.so.2 =7gt; /lib/ld-linux.so.2 (0x00110000)Copy the shared libraries identified above to your new
libdirectory under/home/ftpdirectory:[root@deep ] /# cp /lib/libc.so.6 /home/ftp/lib/
[root@deep ] /# cp /lib/ld-linux.so.2 /home/ftp/lib/
Require only if you are not using the
--enable-lsoptionRequire only if you are not using the
--enable-lsoption
These library are needed to make
lswork. Also, steps 3 and 4 above are required only if you want to use thelsLinux binary program instead of the--enable-lsoption that uses the new internallscapability of Wu-ftpd.
Create your
/home/ftp/dev/nullfile:[root@deep ] /# mknod /home/ftp/dev/null c 1 3 [root@deep ] /# chmod 666 /home/ftp/dev/nullCopy the
groupandpasswdfiles in/home/ftp/etcdirectory. This should not be the same as your real ones. For this reason, we'll remove all nonFTPusers except for the super-userrootin both of these files,passwdandgroup.[root@deep ] /# cp /etc/passwd /home/ftp/etc/ [root@deep ] /# cp /etc/group /home/ftp/etc/Edit the
passwdfile, vi/home/ftp/etc/passwdand delete all entries except for the super-userrootand your allowedFTPusers. It is very important that thepasswdfile in the chroot environment has entries like:root:x:0:0:root:/:/dev/null ftpadmin:x:502:502::/ftpadmin/:/dev/null
We can notice two things here: first, the home directory for all users inside this modified
passwdfile are now changed to reflect the new chrootedFTPdirectory i.e./home/ftp/./ftpadmin/begins/ftpadmin/, and also, the name of the user's login shell for therootaccount has been changed to/dev/null.Edit the
groupfile, vi/home/ftp/etc/groupand delete all entries except for the super-userrootand all your allowedFTPusers. Thegroupfile should correspond to your normal group file:root:x:0:root ftpadmin:x:502:
Now we must set
passwd, andgroupfiles in the chroot jail directory immutable for better security.[root@deep ] /# cd /home/ftp/etc/ [root@deep ] /# chattr +i passwdSet the immutable bit on
groupfile:[root@deep ] /# cd /home/ftp/etc/ [root@deep ] /# chattr +i group