Repository navigation
[v1] add an example of running sftp-server through sudo - #688
Open
christhomas wants to merge 1 commit into
Open
christhomas wants to merge 1 commit into
christhomas wants to merge 1 commit into
Conversation
NewClient always requests the "sftp" subsystem. To get root access like WinSCP's sudo option or `sftp -s "sudo .../sftp-server"`, start sftp-server with sudo on a session and hand its pipes to NewClientPipe.
puellanivis
reviewed
Oct 19, 2026
puellanivis
left a comment
Collaborator
There was a problem hiding this comment.
I think I get an eye-tick thinking about demonstrating to people how to use a footgun…
Contributor
Author
|
You wanna drop it and let them build it themselves :) I'm always quite amused when people use footguns, we can delete this PR if you want |
Collaborator
|
I suppose that’s the thing about footguns… should one show people how it can be done safely, hoping they don’t use it wrong; or should one just not tell them to not stuff beans up their nose? I think if we’re going to put in an example, it might be important to note the risks involved explicitly… |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
For #12.
As suggested in the thread there, this adds an example for
NewClientPiperather than new API:NewClientalways requests thesftpsubsystem, so to get the equivalent of WinSCP's sudo option orsftp -s "sudo /usr/lib/openssh/sftp-server", the example starts sftp-server with sudo on a session (anexecrequest instead ofsubsystem) and passes the session's pipes toNewClientPipe. It notes that sudo must not ask for a password and that the sftp-server path varies by system.I checked the same code against a small in-process SSH server that runs the
execcommand (minus thesudo, which it can't run): the server receivessudo /usr/libexec/sftp-serverand the client can read directories through it.