public void Run() { try { SshConnectionInfo input = Util.GetInput(); SshShell shell = new SshShell(input.Host, input.User); if (input.Pass != null) { shell.Password = input.Pass; } //This statement must be prior to connecting shell.RedirectToConsole(); shell.Connect(); while (shell.ShellOpened) { System.Threading.Thread.Sleep(500); } shell.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } }
/// <summary> /// Get input from the user /// </summary> public static SshConnectionInfo GetInput() { SshConnectionInfo info = new SshConnectionInfo(); info.Host = Console.ReadLine(); info.User = Console.ReadLine(); info.Pass = Console.ReadLine(); Console.WriteLine(); return info; }
/// <summary> /// Get input from the user /// </summary> public static SshConnectionInfo GetInput() { SshConnectionInfo info = new SshConnectionInfo(); info.Host = Console.ReadLine(); info.User = Console.ReadLine(); info.Pass = Console.ReadLine(); Console.WriteLine(); return(info); }
public void Run() { try { SshConnectionInfo input = Util.GetInput(); exec = new SshExec(input.Host, input.User); if (input.Pass != null) { exec.Password = input.Pass; } exec.Connect(); string command = Console.ReadLine(); string output = exec.RunCommand(command); Console.WriteLine(output); exec.Close(); } catch (Exception e) { Console.WriteLine(e.Message); } }