RExec - SSH remote exec
SSH remote exec utility - executes a simple command at the SSH server.
Connects to the specified SSH server, executes a single command and displays the command output. The easiest way of response reading is utilized - check out the Execute simple commands for more information.
This sample demonstrates:
- Using Ssh class.
- Executing a command at the server.
C#
// create an Ssh object Ssh ssh = new Ssh(); // connect to the server ssh.Connect("hostname"); // login to the server ssh.Login("username", "password"); // run a command at the server string response = ssh.RunCommand("dir"); // write the response Console.Write(response); // disconnect from the server ssh.Disconnect();
VB.NET
' create an Ssh object Dim ssh As Ssh = New Ssh() ' connect to the server ssh.Connect("hostname") ' login to the server ssh.Login("username", "password") ' run a command at the server Dim response As String = ssh.RunCommand("dir") ' write the response Console.Write(response) ' disconnect from the server ssh.Disconnect()