You can create a script to intercept the sftp subsystem call on the remote computer. Put the following script somewhere on the remote server, say / root / bin / sftp _intercept:
#!/bin/sh
exec sudo -u less_privileged_user /usr/lib/openssh/sftp-server
and then make the call as follows:
sshfs root@remote:dir mountpoint -o sftp_server=/root/bin/sftp_intercept
This should give the desired results.
You will need a suitable sudoers entry to get sudo to work without asking for a password, and don't forget “chmod 755 ~ / bin / sftp_intercept”.
Also, make sure that / usr / lib / openssh / sftp -server is indeed the path to the sftp server. If not, it might be / usr / lib / sftp-server.
source
share