如何使用SSH.Net运行多个命令?

时间:2015-06-17 12:06:32

标签: c# ssh ssh.net

我正在尝试使用SSH.Net将用户的Wifi mac地址添加到Aruba Wifi控制器,所以我正在运行这些命令:

//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();

但是没有发生并且没有添加用户......

0 个答案:

没有答案
相关问题