Hi,
I've been trying to make this work for a few days now but keep running into problems. I'm trying to make an application for college project to log onto a modem by SSH client and make it do a reboot with a windows form button.
Some information:
MODEM ip: 192.168.1.1
How I do it now:
NOTE: seems that the modem only accepts keyboard interactive login so this is my code:
I've been trying to make this work for a few days now but keep running into problems. I'm trying to make an application for college project to log onto a modem by SSH client and make it do a reboot with a windows form button.
Some information:
MODEM ip: 192.168.1.1
How I do it now:
- Putty
- 168.1.1.1 Port 22
- Putty window says: "login as: "
- I say: "Administrator"
- Putty says: Administrator@192.168.1.1's password:
- I say: "" (empty, no password needed)
- Logged in
- I say: "system"
- I say: "reboot"
-
Modem is rebooted
NOTE: seems that the modem only accepts keyboard interactive login so this is my code:
KeyboardInteractiveAuthenticationMethod keybAuth = new KeyboardInteractiveAuthenticationMethod("Administrator");
PasswordAuthenticationMethod passAuth = new PasswordAuthenticationMethod("Administrator", "");
keybAuth.AuthenticationPrompt += new EventHandler<AuthenticationPromptEventArgs>(HandleKeyEvent);
ConnectionInfo connectionInf = new ConnectionInfo("192.168.1.1", 22, "Administrator", passAuth, keybAuth);
SshClient client = new SshClient(connectionInf);
client.Connect();
client.RunCommand("system");
client.RunCommand("reboot");
and void HandleKeyEvent(Object sender, AuthenticationPromptEventArgs e)
{
foreach (AuthenticationPrompt prompt in e.Prompts)
{
if (prompt.Request.IndexOf("Password: ", StringComparison.InvariantCultureIgnoreCase) != -1)
{
prompt.Response = "";
}
}
}