I am trying to limit a user to only be able to scp in a chroot, no ssh. I want their default directory to be /mnt. I initially used pam_chroot and scp worked but this still gave the user access to ssh. So I'm trying to either use pure jailkit or a combination of jailkit and pam_chroot so that I can disabled ssh.
I followed the howto guide to try and just use jailkit and was able to set up everything apart from jailing the user. I'm on an embedded system that does not have usermod so jailing the user fails. I used jk_init to copy scp (checked that the right dependencies were copied) and jk_lsh to the jail (/mnt), created a user, manually altered /etc/passwd and /mnt/etc/passwd, created a home directory belonging to them in the jail.
add a user to the scp section to have it copied over also to /mnt/etc/passwd.
E.G. users = chrootuser
jk_init -j /mnt scp jk_lsh
chown chrootuser home
chgrp chrootuser home
chgrp chrootuser chrootuser/
chown chrootuser chrootuser/
Currently when I try and scp I enter the user password which is accepted but the command just returns to the prompt with no errors, nothing in the logs. So I thought I'd just use pam_chroot to jail the user. Since I have not jailed the user I am guessing that is why it returns nothing? Unless I am missing something else.
So I enable pam_chroot to create the jail and I get the following complaint:
Could not chdir to home directory /mnt/./home/chrootuser: No such file or directory
I am guessing that pam_chroot is chrooting to /mnt as that is what is set up in it's chroot file, at that point there is no "/mnt" since it has become /?
so I changed /etc/passwd to:
and /mnt/etc/passwd to:
The behaviour then reverts to me trying to scp and it just returning to the prompt with no errors.
Should I be changing my /etc/passwd files to something else? I noticed in the pam_chroot section it said I could use it instead of jk_chrootsh, so maybe that should be removed?
Anything else obvious that I have missed?