Repository navigation
Optional sudo elevation for saved SFTP connections (run sftp-server via sudo) #698
cremenescu
started this conversation in
Ideas
Replies: 1 comment
|
Hi, if such customisation of the sftp subsystem becomes officially supported in the upstream |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Use case
When administering servers, it's common to log in over SFTP as an unprivileged user that has
sudorights, and need to write to paths that user can't normally touch (system config, other users' files, etc.). Today a saved SFTP connection in Nimble Commander always runs with the login user's own permissions, so those writes fail.Current behavior
The SFTP VFS (
SFTPHost) connects via libssh2 and callslibssh2_sftp_init(), which requests the fixedsftpsubsystem. There's no way to elevate within the session.Proposed enhancement
An optional, per-connection toggle (off by default) that, instead of requesting the standard
sftpsubsystem, runs the server's sftp-server binary through sudo over an exec channel — e.g.sudo /usr/lib/openssh/sftp-server— with the binary path being user-configurable in the connection sheet. This is the model WinSCP uses ("SFTP server" command field). The whole session then runs elevated, so writes to otherwise-restricted paths succeed. It requires a matchingNOPASSWDsudoers rule server-side, since the SFTP channel has no TTY.Implementation note / question
The catch is that stock libssh2 only exposes
libssh2_sftp_init(session)and hardcodes thesftpsubsystem — there's no public API to drive SFTP over a custom exec command. So this would need a small addition on the libssh2 side (an init variant that doesexec/custom subsystem) in addition to the VFS + connection-persistence + connection-sheet UI changes.Before I invest in a PR: would you be open to this feature at all, and if so, how would you prefer the libssh2 dependency be handled (carry a local patch in
3rd_Party, push the API upstream to libssh2 first, etc.)? I'm willing to implement it.Alternative considered
Server-side
Match User … / ForceCommand sudo …/sftp-serverworks today with stock Nimble Commander, but it's per-server sshd config rather than something controllable from the client, which is why a client-side option would help.All reactions