I run an ssh server on my machine and I restrict access to certain users to sftp only with internal-sftp & ChrootDirectory. What I need is a way to execute a script before chrooting users. Actually, the goal is to mount an encrypted filesystem on client connection and unmount it on close. Thx in advance.
If you don't want to hack the openssh code you have to use the external sftp server. If you do it is a simple matter of putting a wrapper around it. For example: in
sshd_config
In
/usr/local/bin/sftp-server
:It might be possible to put a wrapper around
sshd
and launch the wrapper frominetd
but launchingsshd
frominted
is discouraged because it is to slow to start up.You can also use pam_script, a pam module to execute script from a pam authentication module. You can add it in your pam sshd configuration. URL: http://linux.die.net/man/5/pam_script