Is there any method, with ChrootDirectory and internal-sftp, to automatically cd to a subdir on login?

Whit Blauvelt whit at transpect.com
Thu May 17 04:25:46 EST 2012


Peter,

Thanks, but as I understand it that's not an applicable answer in my
circumstance. I need each user to have a unique root directory rather than
have users share one.

If the ChrootDirectory were /home and the users were /home/user1 and
/home/user2 what you suggest would work. But in my case the ChrootDirectory
is %h and the place the users need to end up is %h/files. 

This is trivial to do with scponly. Just set the home directory in
/etc/passwd to be /home/user1//files so the chroot is /home/user1 and the cd
is to /home/user1/files. What I'd like is that same functionality using
OpenSSH's internal sftp server.

I need to chroot my users separately rather than to a common chroot because
the users and their files need to be totally invisible to each other, no
matter what.

Best,
Whit

On Fri, May 11, 2012 at 01:34:40AM +0200, Peter Stuge wrote:
> Whit Blauvelt wrote:
> > Thanks for any advice
> 
> Quoting sshd_config(8):
> 
>      ChrootDirectory
>              Specifies the pathname of a directory to chroot(2) to after
>              authentication.  All components of the pathname must be root-
>              owned directories that are not writable by any other user or
>              group.  After the chroot, sshd(8) changes the working directory
>              to the user's home directory.
> 
> So set the home directory to what you want them to land in, relative
> the ChrootDirectory root.
> 
> 
> //Peter
> _______________________________________________
> openssh-unix-dev mailing list
> openssh-unix-dev at mindrot.org
> https://lists.mindrot.org/mailman/listinfo/openssh-unix-dev


More information about the openssh-unix-dev mailing list