Rebex SSH Shell

SSH shell, tunneling, telnet, ANSI terminal emulation library for .NET

Download 30-day free trial Buy from $699
More .NET libraries

Back to feature list...

Easy-to-use API

Execute simple commands 

Executing simple commands using SSH is very easy - just connect to the server, authenticate and call RunCommand method.

using (var ssh = new Rebex.Net.Ssh())
{
    // connect and log in
    ssh.Connect(serverName);
    ssh.Login(username, password);

    // execute a simple command
    string response = ssh.RunCommand("echo Hello world!");

    // display the response
    Console.WriteLine(response);
}
Using ssh = New Rebex.Net.Ssh()
    ' connect and log in
    ssh.Connect(serverName)
    ssh.Login(username, password)

    ' execute a simple command
    Dim response As String = ssh.RunCommand("echo Hello world!")

    ' display the response
    Console.WriteLine(response)
End Using

Tip: RunCommand can only be used to execute commands that don't require any user input. To script advanced commands, use Scripting object instead.

Scripting complex commands 

To execute more commands using a single shell, or to execute commands that actually need some kind of user input, use the powerful Scripting object:

using (var ssh = new Rebex.Net.Ssh())
{
    // connect and log in
    ssh.Connect(serverName);
    ssh.Login(username, password);

    // start a scripting session
    Scripting scripting = ssh.StartScripting();

    // automatically detect remote prompt
    scripting.DetectPrompt();

    // execute command
    scripting.SendCommand("echo Hello world!");

    // read its response
    string response = scripting.ReadUntilPrompt();

    // execute more commands
    // ...

    // display the response
    Console.WriteLine(response);
}
Using ssh = New Rebex.Net.Ssh()
    ' connect and log in
    ssh.Connect(serverName)
    ssh.Login(username, password)

    ' start a scripting session
    Dim scripting As Scripting = ssh.StartScripting()

    ' automatically detect remote prompt
    scripting.DetectPrompt()

    ' execute command
    scripting.SendCommand("echo Hello world!")

    ' read its response
    Dim response As String = scripting.ReadUntilPrompt()

    ' execute more commands
    ' ...

    ' display the response
    Console.WriteLine(response)
End Using

Tip: Check out the list of Scripting features.

Tip: The Scripting object can be used to script TerminalControl or VirtualTerminal objects as well.

Back to feature list...