I try to restrict access to SFTP Only with one User Account. After Login there should some commands be executed.Therefore i inserted forcecommmand in my sshd_config:
Match group stream #ChrootDirectory /home/%u X11Forwarding no AllowTcpForwarding no ForceCommand sudo /etc/mountsftp.sh #ForceCommand internal-sftp
This works fine and my command Script:
#!/bin/bash now=$(date +"%T,%D") echo "Login : $now" >> /login.log sshfs usrl@server:/usbshare1-2 /media/pp -o reconnect -o allow_other -o workaround=all mount --bind /media/pp/Serien /home/stream/Serien J=$HOME # #exit by calling a shell to open for the ssh session #internal-sftp #cp -v /usr/lib/openssh/sftp-server $J/bin/ chroot $J /usr/lib/openssh/sftp-server
is executed. But after the CHROOT its not possible to start the sftp-server, because its not found after chroot. But I need Chroot as well as this sftp-server. Is there any way to accomplish this?
PS: Autofs for the mount is no option, because everything is executed on an vserver without the needed Kernel modules.