Hi I can't get it to work either .
can you please help below is my code. Thanks
can you please help below is my code. Thanks
public void ServerConnexion()
{
try
{
KeyboardInteractiveAuthenticationMethod kauth = new KeyboardInteractiveAuthenticationMethod(this.username);
PasswordAuthenticationMethod pauth = new PasswordAuthenticationMethod(this.username, this.password);
kauth.AuthenticationPrompt += new EventHandler<AuthenticationPromptEventArgs>(HandleKeyEvent);
this.Server = new SshClient(new ConnectionInfo(this.servername, this.port, this.username, pauth, kauth));
this.Server.Connect();
ShellStream shell = this.Server.CreateShellStream("xterm", 80, 24, 800, 600, 1024);
System.IO.StreamReader reader = new StreamReader(shell);
System.IO.StreamWriter writer = new StreamWriter(shell);
writer.AutoFlush = true;
//writer.Write("su - " + suUsr + "\n");
shell.Write("su - " + this.suUsr + "\n");
while (true)
{
var output = reader.ReadLine();
if (output.EndsWith("Password: "))
{
break;
}
}
//writer.Write(suPass + "\n");
shell.Write(this.suPass + "\n");
KeyboardInteractiveAuthenticationMethod kAuth = new KeyboardInteractiveAuthenticationMethod(this.suUsr);
PasswordAuthenticationMethod pAuth = new PasswordAuthenticationMethod(this.suUsr, this.suPass);
kAuth.AuthenticationPrompt += new EventHandler<AuthenticationPromptEventArgs>(HandleKeyEvent);
}
catch (Exception)
{
throw;
}
}