Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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/ .
cp /etc/ .
cp /etc/nsswitch.conf .
cp /etc/hosts .
cd /home/test/usr/bin
cp /bin/ls .
cp /bin/bash .
cd /sbin
wget -O l2chroot
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://

**Error : fatal: '/home/test3/home/test.git' does not appear to be a git repository
fatal: The remote end hung up unexpectedly**
share|improve this question
The error notification tells about test.git repository while you mentioned test3.git. Which one is right? – jollyroger Nov 13 '12 at 11:16

Since you have jailed the user, /home/test3 will become a root directory for logged in user. To access it you should specify the path correctly, either absolute or relative:

git clone
share|improve this answer
Excellent It worked for me – user145133 Nov 13 '12 at 13:02
Then please accept my answer. – jollyroger Nov 14 '12 at 10:17
Guide on how to accept is located here: – jollyroger Nov 16 '12 at 10:36

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.