Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

elrod_johnson

How do I send "sudo /usr/lib/openssh/sftp-server" in .NET

I'm connecting to an EC2 Ubuntu server.
WinSCP works fine in the GUI when I set Advanced Site Settings > Environment > SFTP > Protocol options > SFTP server = sudo /usr/lib/openssh/sftp-server
How do I do this in C# .NET?

Here's the WinSCP.ini section I'm trying to duplicate in .NET:
[Sessions\ec2-server]
HostName=<ip>
UserName=ubuntu
PublicKeyFile=<ppk filepath>
LocalDirectory=<local dir>
RemoteDirectory=<remote dir>
SftpServer=sudo%20/usr/lib/openssh/sftp-server  <<<--- how do i do this in .net

I did see session.AddRawConfiguration, but can't figure out the correct .ini setting

Thanks

SOLVED – with help from https://winscp.net/eng/docs/ui_generateurl
The Generate Session URL/Code is a very useful feature.

Correct format is:
sessionOptions.AddRawSettings("SftpServer", "sudo /usr/lib/openssh/sftp-server");

not
session.AddRawSettings("SftpServer", "sudo /usr/lib/openssh/sftp-server");

Like I was trying.