Sending a restart command to my firewall over SSH with VB.NET

0 votes
asked Aug 1, 2012 by Rebex KB (8,240 points)
edited Aug 1, 2012

I'm trying to write a small program that will send a restart command to my firewall when a button is pressed or a condition is met.

1 Answer

0 votes
answered Aug 1, 2012 by Martin Vobr (12,900 points)
edited Aug 1, 2012

Following code shows how to execute command via SSH on remote *nix server using Rebex SSH Shell component.

' create client, connect and log in  
Dim client As New Ssh
client.Connect(hostname)
client.Login(username, password)

' run the command to restart the firewall
Dim result As String = client.RunCommand("command-to-restart-firewall")

' display the output 
Console.WriteLine("Result: {0}", result)
...