Hi,
You can instruct Rebex SSH to prefer 'keyboard-interactive' if available, and only use 'password' otherwise:
var ssh = new Rebex.Net.Ssh();
ssh.Settings.PreferInteractiveAuthentication = true;
ssh.AuthenticationRequest += (s, e) =>
{
Console.WriteLine("Server: {0}", e.Name);
Console.WriteLine("Instructions: {0}", e.Instructions);
foreach (SshAuthenticationRequestItem item in e.Items)
{
// display the prompt
Console.WriteLine(item.Prompt);
// get answer
item.Response = Console.ReadLine();
}
};
ssh.Connect(host);
ssh.Login(user);
var response = ssh.RunCommand("show int sum");
Console.WriteLine(response);
In this case, the AuthenticationRequest
request handler would be called both for 'keyboard-interactive' (based on what the server asked for) and for 'password' (where it would just ask for the password).