Sending remote commands can be done via SshChannel.RequestExec methods:
// open an SSH session channel over a connected SFTP client
SshChannel channel = sftp.Session.OpenSession();
// execute the 'uname' command to get OS info
channel.RequestExec("uname -a");
// process the command response
var response = new StringBuilder();
var buffer = new byte[4096];
while (true)
{
int n = channel.Receive(buffer, 0, buffer.Length);
if (n == 0)
{
channel.Close();
break;
}
response.Append(Encoding.Default.GetString(buffer, 0, n));
}
Console.WriteLine("OS info: {0}", response);
You can learn more at https://www.rebex.net/sftp.net/features/ssh.aspx#remote-exec
For more complex scenarios, e.g. scripting an SSH terminal, I recommend our Terminal Emulation component that provides a dedicated Scripting API.
Rebex Terminal Emulation can be purchased together with Rebex SFTP for a discounted price as Rebex SSH Pack.