public void ExeSSH(Object s)
{
using (var conninfo = new PasswordConnectionInfo(ip, log, pass))
{
// try
Renci.SshNet.SshClient client = new Renci.SshNet.SshClient(conninfo);
// conninfo.Timeout = TimeSpan.FromSeconds(50);
try
{
client.Connect();
}
catch (Exception ex)
{
}
try
{
Renci.SshNet.ShellStream stream = client.CreateShellStream("ssh", 180, 324, 1800, 3600, 8000);
foreach (string command in list)
{
stream.Write(command + "\n");
System.Threading.Thread.Sleep(5000);
string temp_string = stream.Read();
// File.WriteAllText(path, temp_string, Encoding.UTF8);
File.WriteAllText("C:/" + ip + ".txt", temp_string, Encoding.UTF8);
System.Threading.Thread.Sleep(5000);
}
client.Disconnect();
}
catch (Exception ex)
{
}
}
}