OK..
After chattin with xDamox in #linux-noob. I discovered that maybe the problem wasn't quite as simple as I thought ;)
After setting up the minimal 'jail' from above step in here....
So here goes:
First off install ssh (must be the PAM enabled version)and you also need the libpam_chroot module.
Ok so they should be installed.
Then edit "/etc/pam.d/ssh".
Code:
# PAM config for ssh
auth required pam_nologin.so
auth required pam_env.so # [1]
@include common-auth
@include common-account
@include common-session
session optional pam_motd.so # [1]
session optional pam_mail.so standard noenv # [1]
# heres the chroot for ssh users '/etc/security/chroot.conf'
session required pam_chroot.so
@include common-password
#if you have this comment it out.. it cause problems (like instance logout;))
#session required pam_limits.so
Hopefully a pam 'head' can explain why the limit file gives difficulties... probably something simple.
Ok so now when ssh uses pam it should use the pam_chroot. Thats what we just setup. Now we need to tell ssh to actaully use it [img]<___base_url___>/uploads/emoticons/default_laugh.png[/img]
Edit "/etc/ssh/sshd_config". I'm not going to put in the WHOLE sshd_config file here just the two lines that require to be set the ... represent the rest of the file.
Code:
#normally this is yes.. so switch to no
UsePrivilegeSeparation no
#normally this is yes...but check
UsePAM yes
Ok it should be stressed that you should NEVER run ssh with UsePriv.. set to no unless you plan on chroot'in. This basically gives ssh the ability to be root, this can lead to real dangers. We need it to run as root because we cannot chroot the user into the new chroot enviroment unless we are root.
Right.. so sshd is ready... Now to finish off the PAM setup.
Edit "/etc/security/chroot.conf"
NOW we're ready.... Restart your ssh daemon to get the new config:
Code:
/etc/init.d/sshd restart
Well thats it. The ssh daemon will now force a user into the chroot 'jail' using PAM. Lets test...
Code:
# ssh -l znx localhost
Password: *******
Last login: Fri Mar 25 19:28:08 2005 from localhost.localdomain
-bash-2.05b$ ls
-bash: ls: command not found
-bash-2.05b$ logout
Connection to ubuntu closed.
#
Woot.. were there.. that's it.. now you can add the binaries/libraries that you wish to allow the user access to (mv cp ls, etc).
Be careful of course... no suid binaries should ever be installed these will basically give the change for your chroot 'jail' to be compromised.
You may think about renaming bash to rbash to be a little more aggressive in the restrictions of your shell.