Providing subcommands to a command (sudo/su) executed with SSH.NET SshClient.CreateShellStream
Just write the “commands” to the StreamWriter. writer.WriteLine(“sudo su – wwabc11”); writer.WriteLine(“whoami”); // etc See also C# send Ctrl+Y over SSH.NET. Though note that using CreateShellStream (“shell” channel) is not the correct way to automate a commands execution. You should use CreateCommand/RunCommand (“exec” channel). Though SSH.NET limited API to the “exec” channel does not support … Read more