0

I am trying to use WinSCP using Visual Studio. I am able to login to the remote machine using my own credentials using the WinSCP code. After login, I would need to do a sudo user to move another file.

How to connect to a different user within WinSCP?

My current code is like this:

Session session = null;

try
{
    // Setup session options               
    SessionOptions sessionOptions = new SessionOptions
    {
        Protocol = Protocol.Ftp,
        HostName = HostName,
        UserName = UserName,
        Password = Password,
        Timeout = TimeSpan.FromDays(1),
    };

    using (session = new Session())
    {
        // Connect
        session.Open(sessionOptions);
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
venkat14
  • 583
  • 3
  • 12
  • 34

1 Answers1

1

There's no "sudo" in FTP protocol.

If you need to perform an operation using different credentials, you need to open a new session (new Session instance) using those credentials.

See also WinSCP FAQ How do I change user after login (e.g. su root)?

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992