Oussema Cherni bio photo

Oussema Cherni

Linux Systems engineer & Internet side-preneur From Tunisia

Twitter Google+ LinkedIn Instagram Github

Copie des lib nécessaires

#!/bin/bash
 
mkdir -p {bin,dev,lib,lib64}
mknod dev/null c 1 3
mknod dev/zero c 1 5
chmod 0666 dev/{null,zero}
 
TMPFILE1=./temp1
TMPFILE2=./temp2
 
APPS="/bin/bash /bin/cp /bin/ls /bin/mkdir /bin/mv /bin/rm /bin/rmdir /usr/bin/id /usr/bin/rsync /usr/bin/scp /usr/bin/wget /usr/bin/vim /usr/bin/vi /bin/cat /bin/less /usr/bin/tail /usr/bin/clear /bin/chmod"
 
for app in $APPS;  do
    if [ -x $app ]; then
        app_path=`dirname $app`
        if ! [ -d .$app_path ]; then
            mkdir -p .$app_path
        fi
        cp -p $app .$app
        ldd $app >> ${TMPFILE1}
    fi
done
 
for libs in `cat ${TMPFILE1}`; do
    frst_char="`echo $libs | cut -c1`"
    if [ "$frst_char" = "/" ]; then
        echo "$libs" >> ${TMPFILE2}
    fi
done
 
for lib in `cat ${TMPFILE2}`; do
        mkdir -p .`dirname $lib` > /dev/null 2>&1
        cp $lib .$lib
done
 
cp -r /lib/terminfo ./lib/
 
rm -f $TMPFILE1
rm -f $TMPFILE2

On ajoute la config à la fin de /etc/ssh/sshd_config

Match User userchrooted
ChrootDirectory /home/chroot
AllowTCPForwarding no
X11Forwarding no