ssh.net GetData
ConnectionInfo pci;
try
{
pci = new PasswordConnectionInfo(host, port, username, password);
}
catch (Exception ex)
{
if (ex.ToString().Contains("No suitable authentication"))
{
KeyboardInteractiveAuthenticationMethod keybAuth = new KeyboardInteractiveAuthenticationMethod(username);
keybAuth.AuthenticationPrompt += new EventHandler<AuthenticationPromptEventArgs>((sender, e) => {
foreach (AuthenticationPrompt prompt in e.Prompts)
{
if (prompt.Request.IndexOf("Password:", StringComparison.InvariantCultureIgnoreCase) != -1)
{
prompt.Response = password;
}
}
});
pci = new ConnectionInfo(host, port, username, keybAuth);
}
else
{
throw ex;
}
}
string xterm = "vt220";
using (var client = new SshClient(pci))
{
client.Connect();
ShellStream shellStream = client.CreateShellStream(xterm, 80, 24, 800, 600, 1024);
shellStream.DataReceived +=(sender,e)=> { };
}