Copyright © 2005 The FreeBSD Documentation Project
This book describes FreeBSD Jails. It was written for [BG] BSDcon 2005
���������! ������ ��, �� ���я�я���� ������� ��� ��я�� �����. �� ���� � ������������� �я? ��� ������ ���� ������, ����� ������ ���� �� Apache, PHP, MySQL � ����я��� chroot(8). ���� ����� �������� ������� �� jail(8) - ��������� �� FreeBSD �� �����я�� �� �я�� ������� �����, ��������� � ���� ��������� IP �����. ���� ����������� �� �� ������� �� ��������� "������", � ����� �� ������я��� ����������� ��-���� ������.
����������� �� �������� �������я: ������� ��� ����������� � ������������� Apache �� ������ �������. �� �� ������я�� � ������������ �� nobody � �������� ������������. ���� � �� �� ��я�� "��������" - ���� ��������� � ��������� �� ������������ �� nobody ����������я�. �я�����, �� � ���-����я� ������ ���������я� ���� �� ������ ����я� ����.
�� �� � ������ ����. ��, ���������я� ���� �� ������ ����я� ����, �� ��� ���� �� ������� ����� ������. ��� ���� �� �������� ���������/������������ ��� ������ �������, �� ����� ����� �� /etc/passwd, �� ���� Apache � �.�. �� ��� ��� ���� �����, �������� ��� "���������" �� ������, �� ���������я� �� �� ����� �� �������� root ������ �� ������ �������.
|
����������� ����� �� ��������� � UNIX, ���: "���, root, ����� �������?" |
||
| -- Jails: Confining the omnipotent root. | ||
�я�� �� �� �� ����������� ��-�����, ��� ���������я�:
������� � ������� �������� ��������?
�я�� ������������ �� �������/������ ����я� ����?
�я�� ������������ �� �������/������ ������ �����?
�я�� ���������� �� �������� ���������/������������ ��� ������ �������?
�� ���� �� �� � ����� � ��������я� �� /etc/passwd?
�я�� ���������� �� ��������� ����� ������� ������?
�� ���� �� ������ ���я� IP ����� �� �������� �� Apache?
����� �����? ����������� � � FreeBSD.
� ���� ����� �� ������� �����я�� � ������ ��������, ����� �� ��я��� �� ������.
��������� �� FreeBSD ���������� ���я�� �� chroot(8). ����������� chroot(8) ������ �� ��������� ����� �� ����������, �� �� ��������� � ������ ���������� �� ������������ �� ������ ������ (/etc, /tmp, /usr, /var, /lib � �.�.). �����я�� �������� ������� (/etc/passwd, /etc/group ..), ������� ���������� � ������ ����������. ������ ��������� ������������ ��� chroot(8) ������������ �����, �� ���� ������������ ��������� � �������� �������.
jail(8) ����� ������ � �я����� ������������ ����:
�я���� IP ������� ������ ���� ���� ��������� IP �����.
������� �� �я��� ����������я �� ���� я��� �� ��������� � ������� (���������� root � ������� �� ���� �� ������я IP ������� �� �������, ������я� gateway, ������� �� ��������� �����, �� ���� �� �������� mount(8), ���� �� ����� �������/������� ����� ������� � �.�.)
�������� ������ �����, �� �� � ������? � ����� ������ - ���� ���������.
�� �� �������� �� ����� ����� �� �������� ���������� �� ������������:
# export FORCE_PKG_REGISTER=1# export J
='/usr/jails/web'![]()
Note: ���� �я�� �� ��������� root �������� ������. ���� �, ������ ��� ��������� :)
� ���� ����� �� ����������� ���������, ��������� � ������� � ��������������� �������.
���� ��������� �� ���� ����� �� ������:
��� �� ����������� MySQL, ����������� port ��������� �� FreeBSD.
��� �� ����������� Apache.
��� �� ����������� PHP � ��������� �� MySQL.
����� �� ��������� ���� ����� ��я��� �� ��� ��������� �:
�� ����������� databases/mysql40-server.
cd /usr/ports/databases/mysql40-servermake clean
make install
![]()
�� ����������� www/apache13.
cd /usr/ports/www/apache13 make clean make install \ CONFIGURE_ARGS='--prefix=/apache --with-layout=FreeBSD --datadir=/apache/www --htdocsdir=/apache/www/data --cgidir=/apache/www/cgi-bin --server-uid=nobody --server-gid=nobody --enable-module=so --enable-module=auth_db --enable-module=mmap_static --disable-module=auth_dbm --enable-shared=max'\DOCUMENT_ROOT
='/apache/www/data'\CGIBIN_ROOT
='/apache/www/cgi-bin'\PREFIX
='/apache'![]()
�� ����������� lang/php5.
cd /usr/ports/lang/php5 make clean make install make install PREFIX='/apache' APXS='/apache/sbin/apxs'![]()

�� ����������� databases/php5-mysql
���� ���������� �� ���� mysql.so �������. ��� �� �������� �� PHP �� ������ � MySQL ���� �����.
cd /usr/ports/databases/php5-mysql
make install
make install PREFIX='/apache'
Apache � PHP ���� ����� �� ���� ���������, �� �� �� ������ ������
�� ������������ php.ini, �� �� �������� PHP �� �������� mysql.so
cp /apache/etc/php.ini-dist /apache/etc/php.iniecho 'extension_dir="/apache/libexec/php"' >> /apache/etc/php.ini
echo 'extension=mysql.so' >> /apache/etc/php.ini
mkdir /apache/libexec/php cp `find /apache -type f -name "mysql.so"` /apache/libexec/php
�� ������������ httpd.conf, �� �� �������� Apache �� ���������� PHP ���������.
chown-Rnobody:nobody /apachesed
-e's/\/var\/log/\/apache\/logs/' /apache/etc/apache/httpd.conf > /tmp/httpd.confmv /tmp/httpd.conf /apache/etc/apache/httpd.conf sed
-e's/DirectoryIndex/# DirectoryIndex/' /apache/etc/apache/httpd.conf > /tmp/httpd.confmv /tmp/httpd.conf /apache/etc/apache/httpd.conf cat
<<END_OF_APACHE_CONF>> /apache/etc/apache/httpd.conf<IfModule mod_php5.so> AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps </IfModule> DirectoryIndex index.html index.php
END_OF_APACHE_CONF



DirectoryIndex, �� �� ����� �� я �������
��-�����.
DirectoryIndex,
�� �� �������� Apache �� ������� index.php � index.html, ������ ��
����������� � ���������я.������ �� ��� �� ��������� ���� ��я� �� ��-����� �� 7 ���? :)
���� ��������� �� ���� ����� �� ������:
����� �������/���������� �� ������ � ����я� ������.
��� �� �������� ������� �� ������я� ������� ���������� � ����я� ������.
��я��� �� �������� �я����� �����/����������.
mkdir-p$J $J/bin $J/dev $J/etc $J/lib $J/libexec $J/tmp $J/usr/sbin $J/var/log $J/var/run $J/nonexistentcd $J touch var/log/console.log
chmod
1777tmpcd $J/etc
cat <<MASTER_PASSWD_END > master.passwd root:*:0:0::0:0:woot:/nonexistent:/usr/sbin/nologin nobody:*:65534:65534::0:0:Unprivileged user:/nonexistent:/usr/sbin/nologin MASTER_PASSWD_END cat <<PASSWD_END > passwd root:*:0:0:woot:/nonexistent:/usr/sbin/nologin nobody:*:65534:65534:Unprivileged user:/nonexistent:/usr/sbin/nologin PASSWD_END cat <<GROUP_END > group wheel:*:0: nobody:*:65533: nogroup:*:65534: GROUP_END pwd_mkdb
-d$J/etc $J/etc/master.passwd![]()
echo 'nameserver 127.0.0.1' > resolv.conf echo '192.168.0.13 webjail' > hosts cp /usr/share/zoneinfo/Europe/Sofia localtime cd $J ln
-sfdev/null kernel![]()
cp /bin/sh bin/ cp /usr/sbin/chown usr/sbin/ cp /bin/chmod bin/ cp
-R/apache $Jmkdir
-papache/logs



1777, �������� �� chmod(1) ��������
"����� ����� �� ������, ������ � ����������� ��: ����������, ����� �� ����������, ������
�������� � ���� ����� 'sticky bit'". sticky(8) ����� �����
���������я�� ���������. ������ ��� � ������� - �����, ����� ��� ������� ����������
�� ���������я�� ���� �� ������� �������/����������, �� �� ����������, ��� �� ��
������я�� ��� ��� � ����� ����������. ���� ������ ���������я�� � o+rwx, �������� �� ����������я� � ��������� ���� �� ����
�������, ����� ��� ���������.
Note: ��������, �� �������� �я���� ����� �� root ����������. ����� �� ���������� �������� ��� ����, ��.. /etc/rc.d/jail �������� ��������, �����������
-Uroot ����я��, ���� �� ��я��� �� ������� � ���� ����������. ��� ��� �������� - ������ �� ���������� root � wheel �� passwd, master.passwd, group ���������. � ����� ������ �� �� ������ �� ����������-Uroot�� /etc/rc.d/jail.





����я� ��я� ��� ����� �� �я� ;)
cd $J cp /libexec/ld-elf.so.1 libexec/cp /var/run/ld* $J/var/run
![]()
ldd
-a`find /apache -not -type d` 2>& /dev/null | grep-v':$' | awk '{print $3}' | sort | uniq > /tmp/reqlibs ldd-a/bin/sh 2>& /dev/null | grep-v':$' | awk '{print $3}' >> /tmp/reqlibs ldd-a/usr/sbin/chown 2>& /dev/null | grep-v':$' | awk '{print $3}' >> /tmp/reqlibswhile read f do d=`dirname $f` mkdir
-p$J$d cp $f $J$d done < /tmp/reqlibs rm-rf/tmp/reqlibs![]()





������ ���������� �� �������� � ��� �����������я.
���� ��������� �� ���� ����� �� ������:
��� �� ���������� ������.
��� � ������� � ��� �� �� ����������.
��� ������� �������� ����� �� ������������. (����������� chflags(1))
����� �� ��������� ���� �����, ����я�� �� ������ �� ����������:
��� ��� ����� �� ���������� ����я� ������:
jail $J testapache 192.168.0.13 /bin/shchown
-Rnobody:nobody /apache cd /apache chmod-R500 *chmod
-R600 logsexit
![]()

Note: IP �������, ����� �� ���������� ��я��� �� �� �������� �� ���������. ������ �� ���������� 127.0.0.2 �� ������я �����:
ifconfig lo0 alias 127.0.0.2 netmask 255.255.255.0



����� ������������ �� ��������� �я��� �������/���������� �� �������:
cd $J unlink apache/www/data mkdir apache/www/data rm-rfbin/sh usr/sbin/chown bin/chmod apache/www/data-dist etc/passwd etc/master.passwd![]()
cat <<
END_OF_TEST> apache/www/data/index.php <?php if(mysql_connect(":/tmp/mysql.sock", "root", "")) echo("You have successfully configured Apache, PHP and MySQL :)"); ?>END_OF_TEST
������ �я��� ������� �� �������:
chflags-R schg,sunlnkapache bin etc lib libexec usr var/run/ld* nonexistentchflags
-R noschg,nosunlnk,sappendapache/logschflags
-R noschg,nosunlnkapache/www![]()

schg) � "system undeletable"
(sunlnk) ������� �� ������������. ��������� chflags(1) �� ������
���������я.
sappend) ������� �� ���� �������. ����
��������, �� ���� ������� �� ����� �� ����� �������/������������, ����� ��� ��������� ��
�� -��������- ��� ���������. �� ������ ���������я �������� �������� �� �
���я�� -f �� tail(1).
�� �� �� �������� ����я ������ ����������� ��я��� �� ������� �я����� ���� � /etc/rc.conf � /etc/devfs.rules
���� ��������� �� ���� ����� �� ������:
����� ��я��� �� ������� � /etc/rc.conf, �� �� �������� ��������� ����������� �� �������� �������� � MySQL ��������.
����� ��������������� ����� �� ������� �� �������.
��� �� ������я�� devfs(8) ��������� � �������.
����� �� ��������� ���� ����� ����я��� �� ������ �� ����������:
��я��� �� �������� IP ��������, �������� � MySQL �������. �� ���� ��� ��я��� �� ������� �������� � /etc/rc.conf
ifconfig_fxp0="inet 192.168.0.2 netmask 255.255.255.0" ifconfig_fxp0_alias0="inet 192.168.0.13 netmask 0xffffffff"
mysql_enable="YES" mysql_args="
--bind-address=127.0.0.1--socket=/usr/jails/web/tmp/mysql.sock"jail_enable="YES" jail_list="web" jail_set_hostname_allow="NO" jail_socket_unixiproute_only="YES" jail_sysvipc_allow="NO" jail_getfsstatroot_only="YES" jail_allow_raw_sockets="NO" jail_chflags_allowed="NO"
jail_web_rootdir="/usr/jails/web" jail_web_hostname="web" jail_web_ip="192.168.0.13" jail_web_exec_start="/apache/sbin/httpd" jail_web_exec_stop="" jail_web_devfs_enable="YES" jail_web_devfs_ruleset="webjail" jail_web_mount_enable="NO"


--socket=/usr/jails/web/tmp/mysql.sock'" ��� ����я� .bash_profile ��� start-up ������� �� ����������я� �� ���
shell.
jail_enable: ��������� ��������� ��� ���������� ��
���������.
jail_list: ������ ��� �������, ����� ��я��� �� �����
����������. � �������� �������я ����� ���� ���� ������, ������� "web".
jail_set_hostname_allow: �� ����� �� ��������� ������� ��
hostname � �������?
jail_socket_unixiproute_only: �������� ����������� ��
UNIX/IPv4/route ������ � �������?
jail_sysvipc_allow: ����� �� ��������� � ������� ��
��������� System V IPC primitives?
jail_getfsstatroot_only: ��������� ������ ����
�я����� root ������� ������� � getfsstat()
jail_allow_raw_sockets: �� ����� �� ��������� � ������� ��
�������� "raw" ������?
jail_chflags_allowed: �� ����� �� ��������� � ������� ��
������я� ������� �� �������?
Note:
jail_chfalgs_allowed� �������� ��� FreeBSD 5.4

jail_web_rootdir: ���� � ������� �� ��������? (������� ��
������������ $J?)
jail_web_hostname: ����� �� �������
jail_web_ip: IP ������� �� �������
jail_exec_start: ���������, ��я�� ��я��� �� ��
�������, �� �� �� �������� �������. � ����я� ������ ��я��� �� ���������� Apache, ����������� /apache/sbin/httpd
jail_exec_stop: �я���� ����� �� ����, ������ /etc/rc.jail ������� -TERM ������ ���
Apache ����� -KILL. �� ���� ����� Apache ���� �� ������� �������� ��, �� ������� ������ ������� ������,
�� ������ �������� � �� �� ���� ������������;)
jail_devfs_enable: devfs(8) � /dev ?
jail_devfs_ruleset: ��� ��������� /dev - ��� ������� �� ����������?
Note: �� �� �������я�����, ��������� �� ����� ��������� � ���������� �����я.
jail_web_mount_enable: ������� ������������ �� mount(8) ������� �
�������?
��я��� �� ����� �я����� �������, ����?
�������� �������� � /etc/devfs.rules
[webjail=13]add hide
![]()
add path null unhide add path 'net' unhide add path 'net/*' unhide add path 'net?' unhide add path 'fd' unhide add path 'fd/*' unhide add path 'std*' unhide add path 'random' unhide add path 'urandom' unhide add path 'zero' unhide
��������, ������я���� �� host ��������� ���� ��я��� �� ����� �������������. ��������, ��� ������я���� sshd(8) - ��я��� �� �� ������������� ����, �� �� ������ ������ ���� �� ������ �� host ���������. ��� �� ������� ������� ������ �� ������������� �� �я��� ������.
���� ��������� �� ���� ����� �� ������:
��� �� �������� sshd(8) �� ������ ������ ���� �� host ���������.
��� �� �������� inetd(8) �� ������ ������ ���� �� host ���������.
��� �� �������� Apache �� ������ ������ ���� �� ��������� IP �����.
��� �� �������� MySQL �� ������ ������ ���� �� host ���������.
��� �� �������� named(8) �� ������ ��я��� �� ��������� ������ �� IP ������.
��� �� ��������� ��я��� ��� ������, ����� �� ��������� ������� ����� �� �����������я ����������� ������� �����.
�� �� ��������� ���� ��� �� ������ �� ������������ /etc/ssh/sshd_config. ���������������я� ���� �� ������������
��� ����������� ����я, �������� ListenAddress �
�я �������� �� ������я� �����:
#ListenAddress 0.0.0.0
������ ���� ����я � ����������� sshd(8) ������ ������ �� ����� IP �����. �������� ��я��� �� ��������� ��������� � �� �������� ������ ��������:
ListenAddress 192.168.0.2
� ���� ������ 192.168.0.2 � ������� �� ������ host �������. ��� ��я��� �� �� ��������, ����������.
���� ����я�� �� /etc/ssh/sshd_config ��я��� �� ������������ sshd(8):
/etc/rc.d/sshd restart
inetd(8) ���� ������ ������ �� ����� IP �����. �� �� �������� ���� �������� ��я��� �� ������� ������я� ��� � /etc/rc.conf:
inetd_flags="-wW -a 192.168.0.2"
���� ��я��� �� ������, �� �� ������ �� ��������� 192.168.0.2.
���� ����������я �� /etc/rc.conf � ����������� ������������ �� inetd(8):
/etc/rc.d/inetd restart
Apache �� ����� �� ����я�
�����. �� �� �� �������� �� �������� ���� ���� IP ����� ��я��� �� �������� httpd.conf. �������� ����������� Listen. ��� ��� ������ �� ���� Listen
directives - ������������ �� � �� ��������� ��� ��������:
Listen 192.168.0.2:80
���� �� ������ Apache �� �������� ���� ���� 80 �� ������ host �������. ���� ����������я �� httpd.conf �� ������ ������������ �� Apache:
apachectl restart
��� ��� ����������� Apache ����������� ports/packages ������, ����� ��я��� �� ��������� � /etc/apache/httpd.conf � ������ �� ������������ ������� ��� �������� �������:
/etc/rc.d/apache restart
����я�� ���������� �� MySQL
���� � ����� ������. ��я��� �� �������� --bind-address
����я�� �� ��������� mysqld_safe. ��� ���� ������:
mysqld_safe --bind-address=192.168.0.2
��� ��� �������� ������������ � ��� ����������� MySQL �� FreeBSD port ��������� ��я��� �� �������� ���� ��� � /etc/rc.conf, �� ��� ���� ��������� ���� � �������� �����.
���������������я� ���� �� named(8) � /etc/namedb/named.conf. ��� ��я��� �� ��������� ����я��
listen-on � �� �������� IP �����, �� ����� named(8) �� ������
��я��� (��� ������ �� IP ������)
�� ������������ ���� ��� �������� ����:
listen-on { 127.0.0.1; }
��� ���� � �����я� - named(8) ����� ���� �� 127.0.0.1 � �я�� ����� �� ����я��.
�����я�� �� ������� ����� �� ���� ����������� ������ ��� �� �������� ������, ����� �� ��������� ������� �����������. ���� �� ������� ���� �� ���������я ������ ���� �� 80�� ���� �� IP ������ �� �������. ������ ������ �� ����я� IP ����� �� �������� ������� ��������� TCP RST (“Connection Refused”).
������ ����, �� �� �������� ���������я�. ������ ��� ������ TCP RST - ���������я� ������ �� �������, �� �� ������я ����� ������� �����.
��� ��� �� ���������� ����я� ������ � MySQL ������ ��� ������������ �� �я���� �������
���� ��������� �� ���� ����� �� ������:
��� ����� �� �������/������ ������.
��� ����� �� �������/������ MySQL �������.
�������� ������
���� ��������� �� ���� ����� ��� �� ������ ��:
��������� ipfw(8) ������� �� ����я� ������.
����� �� ��������� ���� ����� ����я��� �� ������ �� ����������:
http://freebsd.org/doc/handbook/firewalls.html
���� �������� ������ �������� ipfw(8)
#!/bin/sh cmd="/sbin/ipfw-q add" out="fxp0"real_ip="192.168.0.2"
jail_ip="192.168.0.13"
ks="
keep-state" /sbin/ipfw-q -f flush$cmd
1000 allow all from any to any vialo0 $ks![]()
$cmd
1001 allow tcp from me to any 53 out via$outsetup$ks $cmd1002 allow udp from me to any 53 out via$out $ks $cmd1003 allow all from any to me 22$ks$cmd
1004 allow all from$real_ipto any out via$outsetup$ksuidroot$cmd
1005 allow tcp from any to$jail_ip 80via$outsetup$ks![]()
$cmd
1006 reset all from any to$jail_ipvia$out $cmd65534 deny log all from any to any










���� ����� �� ����� �������� �� ������������ �� FreeBSD ���������.
���� ��������� �� ���� ����� �� ������:
��� �� ����������/������ ������.
��� �� ��������� ������� � ������.
��� �� ��������� ��� ������� �� ������я��� � ������.
��� �� �� �������� � ���������я ������� ���������� �������.
�������� �� �я�����:
�� �� ���������� ������ ���� ������ ��я��� �� ���������� ��������� jail(8). ����� �� �������� ���������:
path - ��� ��� �������.
hostname - ��� �� �������.
ip-numer - IP ����� �� �������.
command - �������, ��я�� �� �� ������� (�������� /bin/sh)
�� �� ������ ����� ���� ������ ��я��� �� ���������� killall(1). ������:
killall -j 1
������ 1 � ��������������� �� �������. (������
���������я �� ��������������� - ���� �����) �� �� ����������/������ ���������� ���� ������ ������ �� ���������� /etc/rc.d/jail. �� �� ��������� ���� ����� ��я��� �� �������
��������������� ����� � /etc/rc.conf. ���� ���������� ����,
���� �� �������� ������ �� ���������� /etc/rc.d/jail start/stop.
������ �� ���������� jexec(8), �� �� ��������� ������� � ������. �я ������ ��� ���������:
jid - ������������� �� ������
command - ����� ��� �� ���������
���я � ������� �� ������ ��� ������� �� ������я��� � ������. ������ �� ���������� ps(1), �� �� ���������.
������:
ps auxww | grep 'J'
��� �������� �� ������я�� � ������, �� ��� ��� 'J' ���� � STAT. ����������� 8���� ������ �� ������ �� ps(1). ��� ��� 'J' - �������� � � ������.
���� ����� �� ��������� ��� ������� �� � ������ � �� ���������� jps - �������� �� ����� sysutils/jailutils.
������ �� �� �������� � �я���� ���������я, ��я�� �� ��я���, ����������� jls(8). ������:
# jls
JID IP Address Hostname Path
1 192.168.0.13 web /usr/jails/web
�������� JID � ��������������� �� �������. ���� ������������� �� �������� ��
����я�� -j �� killall(1)'s -j, ��������� jexec(8) � ��������
������� �� ������ sysutils/jail* (���������� �����).
Sometimes the default FreeBSD utilities for managing jails are not enough. Here are described some packages that you might want to use.
After reading this chapter you will:
Know something more about the available utilities for managing jails.
sysutils/jailadmin is a system for managing a set of named jails.
It is designed to provide more flexible functionality than FreeBSD's own /etc/rc.d/jail script and provides the following features:
A command line utility for starting and stopping named jails.
An efficient method for shutting down a large number of jails in parallel.
A simple configuration syntax.
SNMP monitoring facilities.
I have never used this utility but you might want to play with it. The SNMP monitoring sounds good.
This utility must be installed inside the jail and has the ability to shutdown/restart it.
I haven't used this utility because calling /etc/rc.d/jail
start/stop does the same thing.
Besides ..jailer creates its own process inside the jail and if an attacker gains nobody's privileges he is able to list the processes and see that
he's actually into a jail.
Anyway, the injail command in this package looks interesting. It determines if a process is running inside a jail and might be used for scripting purposes.
Another way to determine if a process is running in jail is to parse the output of ps(1)
This utility builds a chrooted environment. The same thing we did in chapter 4. Its main goal is to create a list of proper libraries to be copied and create the environment.
We haven't used this utility because our task was simple and didn't require such tools.
If you want to create a fat jail environment with all the tools/programs you need - consider reading jail(8) It has a wonderful example.
This package has some neat utilities that can be used for scripting purposes.
jps - List processes in jail
Note: In order this to work you need /bin/ps in the jail's directory tree.
jid - Print id of jail
jails - List running jails.
injail - Determine if a process is running in a jail.
It also has some other utilities for starting/stopping jails. If you want more information - install the package :)
This package has only one application, called jkill.
It shutdowns a running jail and all its processes.
Anyway, you can achieve the same thing (and even more) with /etc/rc.d/jail stop
After reading this chapter you will:
Know where to find some more articles about FreeBSD jails.
The jail(8) manual describes a way of creating a fat jail. The whole idiea is to rebuild your world and put -anything- you need inside the jail environment. This allows you to run all kinds of services, including sshd(8) which could help you with the administration.
Mike DeGraw-Bertsch has written a wonderful article which expands jail(8)
You can find it at http://www.onlamp.com/pub/a/bsd/2003/09/04/jails.html
A paper by Poul-Henning Kamp and Robert N. M. Watson /usr/share/doc/papers/jail.ascii.gz
This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/.
For questions about FreeBSD, read the documentation before contacting <[email protected]>.
For questions about this documentation, e-mail <[email protected]>.