|
|||||||||||
|
Re: chrooting rssh problem
From: Julian Heinbokel <heinbokel(at)unisport.etc.tu-bs.de>
Date: Fri Nov 02 2007 - 16:35:16 EDT
i found the instructions in /usr/share/doc/rssh/CHROOT.gz incomplete, so after a long search i copied together this (ugly) skript, but by reading it you might find the information you are missing. (not quite sure if the above is english, i'm not a native speaker...) #!/bin/bash ##################################################################### ##################################################################### ## ## mkchroot.sh - set up a chroot jail. ## ## This script is modified to work for Debian 4.0 "Etch", but may work on ## other systems. Or, it may not... In fact, it may not work at all. Use at ## your own risk. :) ## ## This is a combination of the "original" mkchroot.sh-script and the ## "setup-chrootdir-rsync.sh"-script. ## These scripts can be found in the rssh-package ## (/usr/share/doc/rssh/examples/mkchroot.sh) and in thelibpam-chroot-package ## (/usr/share/doc/libpam-chroot/examples/setup-chrootdir-rsync.sh). ## ##################################################################### # # Initialize - handle command-line args, and set up variables and such. # # $1 is the directory to make the root of the chroot jail (required)# $2 is the list of users to make home-dirs for # if [ -z "$1" -o -z "$2" ]; then
echo "`basename $0`: error parsing command line" >&2
echo " You must specify a directory to use as the chroot jail
and at least one user." >&2
exit 1
fi
jail_dir="$1"
##################################################################### # # build the jail # sftp_server_path="/usr/lib/openssh/sftp-server" DIRECTORIES="dev home lib usr/lib/openssh" FILES="usr/lib/openssh/sftp-server lib/ld-linux.so.2" # now make the directory if [ ! -d "$jail_dir" ]; then
echo -e "\n\E[1mCreating root jail directory.\E[0m"
mkdir -p "$jail_dir"
if [ $? -ne 0 ]; then
echo " `basename $0`: error creating jail directory."
fi ##################################################################### # # identify and copy libraries needed in the jail # echo -e "\nCopying libraries for $sftp_server_path." libs=`ldd $sftp_server_path | tr -s ' ' | cut -d' ' -f3 | grep /` for lib in $libs; do
mkdir -p "$jail_dir$(dirname $lib)"
echo -e "\t$lib"
cp "$lib" "$jail_dir$lib"
done ##################################################################### # # set up /dev/null # echo -e "\nCreating $jail_dir/dev/null." mknod $jail_dir/dev/null c 1 3 && chmod a+w $jail_dir/dev/null ##################################################################### # # set up "user-environment" #
echo -e "\nSetting up $jail_dir/home/*."
for i in $jail_users; do
##################################################################### # # some good advice... # echo -e "\n\E[1mChroot jail configuration completed.\E[0m\n" echo -e "NOTE: you must MANUALLY edit your syslog rc script to start syslogd" echo -e "with appropriate options to log to $jail_dir/dev/log." echo -e "You will need to edit /etc/default/syslogd:" echo -e "\tSYSLOGD=\"-a $jail_dir/dev/log\"\n" echo -e "You will also need to edit /etc/rssh.conf and /etc/passwd.\n"Received on Fri Nov 2 16:51:27 2007 This archive was generated by hypermail 2.1.8 : Wed Mar 19 2008 - 06:54:15 EDT |
||||||||||
|
|||||||||||