Oleg, I can't thank you enough for your help. I really wish I could provide you with a host to test with, but Big Corporate Governance won't let me.
I find that if I pass the correct username and password, the KeyboardInteractiveConnectinInfo shows IsAuthenticated = true after I connect, but I get an Invalid Credentials if I invoke SshCommand.Execute() on a command object created with CreateCommand()
on an SshClient object to which I passed my KeyboardInteractiveConnectionInfo in the constructor.
If I pass bogus credentials, I get an exception when I call Connect().
I'm afraid I don't understand SSH well enough to discuss this intelligently. I wish I could provide more information to help you help me.
1 KeyboardInteractiveConnectionInfo connectionInfo = new KeyboardInteractiveConnectionInfo(t.machineName, username);
2 connectionInfo.AuthenticationPrompt += kAuth_AuthenticationPrompt;
3 SshClient ssh = new SshClient(connectionInfo);
4 ssh.Connect(); <--this appears to work with correct creds, exception otherwise
5 SshCommand cmd = ssh.CreateCommand("ls");
6 cmd.Execute(); <-- I get back "invalid credentials" in cmd.Result
After line 4, connectionInfo.IsAuthenticated = true. (This line throws an exception if I pass known-bad username/password.)
Line 6 is where I get back "Invalid Credentials" from the server. Running this command via PuTTY works.
Am I missing a step in this sequence? Are there other options that I'm not setting or calls that I'm not making?
Here's the code where I handle the authentication prompts. I only get one prompt, and since I don't get an exception when I use the correct credentials, I assume it's working.
void kAuth_AuthenticationPrompt(object sender, Renci.SshNet.Common.AuthenticationPromptEventArgs e)
foreach (Renci.SshNet.Common.AuthenticationPrompt prompt in e.Prompts)
if (prompt.Request.Substring(0, 8).Equals("password", StringComparison.InvariantCultureIgnoreCase))
prompt.Response = (password);