Saturday, 23 June 2012

chroot jail with ssh

from https://help.ubuntu.com/community/BasicChroot
make the chroot structure somewhere.  




$ sudo debootstrap --variant=buildd --arch amd64 precise /home/me/chroot/ http://ubuntu.virginmedia.com/archive/

Then, follow http://forums.gentoo.org/viewtopic-t-374757.html

sudo apt-get install libpam-chroot

sudo vi /etc/security/chroot.conf.  Add user and chroot directory created above, for example,

# to make user `chrooted' get sent to jail in /home/me/chroots/chroot1
chrooted /home/me/chroots/chroot1  

When `chrooted' logs in they will be jailed as above.

sudo vi /etc/pam.d/login.  Add,

# I added the following from 
# http://forums.gentoo.org/viewtopic-t-374757.html
# to turn on PAM chroot jail logins
# /etc/security/chroot.conf, etc/pam.d/login, /etc/pam.d/su also need editing.
session required /lib/security/pam_chroot.so debug

Now,

sudo vi /etc/pam.d/su

#add this line: 
session    required             pam_chroot.so debug




This doesn't work.  :(  The jailed user on login can navigate up above the new home.

There's a program called, `makejail'.  Install it.  Try it.


Or try 
http://www.howtoforge.com/chrooted-ssh-sftp-tutorial-debian-lenny


No comments:

Post a Comment