0

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**
1
  • The error notification tells about test.git repository while you mentioned test3.git. Which one is right?
    – jollyroger
    Nov 13, 2012 at 11:16

1 Answer 1

4

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 domain.com:/home/test3.git
1
  • Excellent It worked for me
    – user145133
    Nov 13, 2012 at 13:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .