I have performed below steps to setup jailed user here username is test3
mkdir -p /home/test3/{dev,etc,lib,usr,bin}
mkdir -p /home/test3/usr/bin
chown root.test3 /home/test3
mknod -m 666 /home/test3/dev/null c 1 3
cd /home/test3/etc
cp /etc/ld.so.cache .
cp /etc/ld.so.conf .
cp /etc/nsswitch.conf .
cp /etc/hosts .
cd /home/test/usr/bin
cp /bin/ls .
cp /bin/bash .
cd /sbin
wget -O l2chroot http://www.cyberciti.biz/files/lighttpd/l2chroot.txt
chmod +x l2chroot
edit the l2chroot
file and change BASE=”/webroot”
to BASE=”/home/test”
. This tells l2chroot
where your jail is located so it copies everything to the right place. Now go ahead and run the command on the binaries you want.
l2chroot /bin/ls
l2chroot /bin/bash
l2chroot /usr/bin/git*
mounted test.git to /home/test3/home/test3.git
mount --bind /path/test.git /home/test3/home/test3.git
created a new group and added test3 user into it changed the group of test.git to git
edited /etc/ssh/sshd_config
Match User test3
ChrootDirectory /home/test3/
X11Forwarding no
AllowTcpForwarding no
PasswordAuthentication yes
Able to do ssh to test3
But while doing git clone ssh://domain.com:22/home/test3/home/test3.git
**Error : fatal: '/home/test3/home/test.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly**