How to run several commands with SSH.Net?

11.3k views Asked by At

I'm trying to use SSH.Net to add users Wifi mac address to Aruba Wifi controller, so I'm running these commands:

//connect to the remove server
SshClient sshclient = new SshClient(hostIP, userName, password);
sshclient.Connect();

//enter the "enable" command and press enter
SshCommand enable = sshclient.CreateCommand("enable");
enable.Execute();

//the "enable" command prompts for admin password, so enter the password and press enter
SshCommand pwd = sshclient.CreateCommand(enablePassword);
pwd.Execute();

//enter "cofigure t" command and press enter
SshCommand config = sshclient.CreateCommand("configure t");
config.Execute();

SshCommand aaa = sshclient.CreateCommand("aaa derivation-rules user ManagersDevices");
aaa.Execute();

SshCommand set = sshclient.CreateCommand("set role condition macaddr equals \"my mac address\" set-value guest description \"test\"");
set.Execute();

SshCommand save = sshclient.CreateCommand("write memory");
save.Execute();

But nothings happens and the user is not added...

0

There are 0 answers