The sftp command supports a subsystem option (-s) which allows the remote user to select the remote sftp-server executable, and optionally upgrade to sudo in the process like so;
sftp -s "/usr/bin/sudo /usr/libexec/openssh/sftp-server" xxx.yyy.zzz.aaa
This command defers to the ssh client options in ~/.ssh/config allowing the transparent use of pubkey and custom port and user settings.
However subsystem
appears to be sftp specific, and hence it not set in the config file and it appears it has to be set as a command line option for sftp.
However some tools wrap the sftp invocation so its impossible to set the subsystem option, and hence stuck with user access.
Is there some configuration option file I can use to set this for openssh sftp generally?
is there some configuration file to effect the way gnome nautilus invokes the sftp for its file manager integration?
Update possible hacky-but-functioning solution is...
So it turns out that there is no obvious config file that sftp will use for options so I ended up modifying a generic wrapper script to add the option explicitly for my selected hosts by putting this in my path;
#!/bin/bash
# Generic shell wrapper that performs an operation
OPERATION=/usr/bin/sftp
args=("$@")
#the final arg should contain a hostname of the form [user@]host[:path]
case "${args[@]: -1}" in
myserver.com)
exec $OPERATION -s "/usr/bin/sudo /usr/libexec/openssh/sftp-server" "$args"
;;
*)
exec $OPERATION "$args"
;;
esac
However depending on your sudoers file, usually to run sudo requires a tty, so you have to pass the "-t" option to ssh, and guess what? there is no configuration option for the ssh client command that is documented that works in the ssh_config or ~/.ssh/config files. haha.
So I write another wrapper script to provide that....
#!/bin/bash
# Generic shell wrapper that performs an operation
OPERATION=/usr/bin/ssh
args=("$@")
#locating the hostname is not so simple with ssh
exec $OPERATION -tt "$args"
although, I am now having trouble getting the sftp to use my ~/bin/ssh wrapper file, as it appears to be hard coded into sftp and controlled by an option "-S"