I've created a simple app which uses the Renci.SshNet library to update firewall configuration on my Fortigate device.
var auth =
new AuthenticationMethod[] { new PasswordAuthenticationMethod(username, password) };
ConnectionInfo ConnNfo = new ConnectionInfo(server, 22, username, auth);
sshclient.Connect();
string command;
string addressname = "testaddress";
command = "config firewall address";
output.Add(command);
output.Add(sshclient.CreateCommand(command).Execute());
command = string.Format(@"edit {0}", addressName);
output.Add(command);
output.Add(sshclient.CreateCommand(command).Execute());
sshclient.Disconnect();
I get the following from the output:
config firewall address
fw1 # fw1 (address) #
edit testaddress
fw1 # Unknown action 0 fw1 #
The same commands work fine over a normal SSH connection.
fw1 # config firewall address
fw1 (address) # edit testaddress
new entry 'testaddress' added
fw1 (testaddress) #
Just wondering if I'm using it correctly sending separate CreateCommans.Execute()
.