Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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**
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
add comment

1 Answer 1

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 absolyte or relative:

git clone domain.com:/home/test3.git
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: serverfault.com/faq#howtoask –  jollyroger Nov 16 '12 at 10:36
add comment

Your Answer

 
discard

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.