我已经执行下面的步骤来设置jailed用户在这里用户名是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
编辑l2chroot文件并将BASE=”/webroot”更改为BASE=”/home/test” 。 这告诉l2chroot你的监狱位于哪里,所以它把一切都复制到正确的地方。 现在继续运行你想要的二进制文件的命令。
l2chroot /bin/ls l2chroot /bin/bash l2chroot /usr/bin/git*
挂载test.git到/home/test3/home/test3.git
mount --bind /path/test.git /home/test3/home/test3.git
创build了一个新的组,并添加了test3用户,将test.git组更改为git
编辑/etc/ssh/sshd_config
Match User test3 ChrootDirectory /home/test3/ X11Forwarding no AllowTcpForwarding no PasswordAuthentication yes
能做ssh来testing3
但是在做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**
由于您已经closures了用户,因此/home/test3将成为login用户的根目录。 要访问它,你应该正确地指定path,无论是绝对的还是相对的:
git clone domain.com:/home/test3.git