Is there any method, with ChrootDirectory and internal-sftp, to automatically cd to a subdir on login?
Peter Stuge
peter at stuge.se
Thu May 17 05:43:22 EST 2012
Whit Blauvelt wrote:
> as I understand it that's not an applicable answer in my
> circumstance. I need each user to have a unique root directory
You can chroot into whatever directory you want, and as the man page
I quoted clearly says there will be a chdir performed after that
chroot, to the directory that has been configured as the home
directory for the user, and naturally that configuration must take
into account the chroot.
> in my case the ChrootDirectory is %h and the place the users need
> to end up is %h/files.
You can obviously not use the home directory to identify the chroot
if you want to use it for chdiring. You can probably quite easily
configure the correct path for chrooting without using the home
directory, and instead set the home directory to /files for the
relevant users to get exactly what you want.
> This is trivial to do with scponly. Just set the home directory in
> /etc/passwd to be /home/user1//files
Sorry, but that is a mindbogglingly bad idea. It is overloading a
case where there is already absolutely well-defined behavior. Of
course it may work, but it may also fail completely in the face of
less typical circumstances. It's neither smart nor elegant to try to
create some conflicting standard where there is already one.
> What I'd like is that same functionality using OpenSSH's internal
> sftp server.
It's documented how you can get the same result and I not only quoted
you the docs but even wrote a quick summary of how it would work.
Try it out! I think it will work fine.
//Peter
More information about the openssh-unix-dev
mailing list