RExec - 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
Reading command response tutorial
for more information.
This sample demonstrates:
- Using Ssh and Shell classes.
- Sending a command to the server.
- Reading a response from 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");
// send the command
Shell shell = ssh.StartCommand("dir");
// get the response of the command
string response = shell.ReadAll();
// 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")
' send the command
Dim shell As Shell = ssh.StartCommand("dir")
' get the response of the command
Dim response As String = shell.ReadAll()
' write the response
Console.Write(response)
' disconnect from the server
ssh.Disconnect()
Included in
See also: