This project is read-only.


Jun 11, 2014 at 4:51 PM

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:

How I do it now:
  1. Putty
  2. Port 22
  3. Putty window says: "login as: "
  4. I say: "Administrator"
  5. Putty says: Administrator@'s password:
  6. I say: "" (empty, no password needed)
  7. Logged in
  8. I say: "system"
  9. I say: "reboot"
  10. Modem is rebooted
Now i tried to script this with normal ip and password, with puttygen and key and convert key to open ssl,....

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("", 22, "Administrator", passAuth, keybAuth);

            SshClient client = new SshClient(connectionInf);
  void HandleKeyEvent(Object sender, AuthenticationPromptEventArgs e)
            foreach (AuthenticationPrompt prompt in e.Prompts)
                if (prompt.Request.IndexOf("Password: ", StringComparison.InvariantCultureIgnoreCase) != -1)
                    prompt.Response = "";
Jun 11, 2014 at 4:53 PM
And when i run the program, it says Client not connected...

Thank you for helping out!
Jun 11, 2014 at 7:38 PM
What version of SSH.NET are you using ?
Please try using the latest beta as there have been some fixes in this area.
You should at least get an SshAuthenticationException when authentication fails.

I tried using keyboard-interactive authentication myself just now, and it works fine for me.
Note that I haven't tried an empty password.

Please verify whether your ssh server indeed is configured to allow empty passwords (PermitEmptyPasswords is false by default, if I'm not mistaken).

Hope this helps,
Jun 12, 2014 at 7:56 AM
Version 2013.4.7.0
Runtime version v4.0.30319

I can connect with putty with an empty password, so I don't think that is the problem?
Thank you so much for helping out Gert! Cant believe you guys are running this project for free, awesome!

An unhandled exception of type 'System.Net.Sockets.SocketException' occurred in System.dll

Additional information: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

With the code above @ client.connect
Jun 12, 2014 at 8:35 AM
    private void btnUpdate_Click(object sender, EventArgs e)
        SshClient client = new SshClient("", "Administrator", "");

        if (client.IsConnected) {
            MessageBox.Show("There is a connection");



As you suggested, I updated to the beta library!
However, it now says There is a connection, but it cannot run the command: Client not connected
Jun 13, 2014 at 7:47 PM
Can you provide the full stacktrace ?
I think that - by the time you execute RunCommand - you're no longer able to write to the socket (but read still works, hence IsConnected returns true).
Don't you have logs on the modem ?