No docs? No test dir? What am I missing?

May 2, 2014 at 1:58 AM
Edited May 2, 2014 at 3:15 AM
Downloaded the latest version, unzip, compiles, everything good so far.

Look for examples on how to simply connect to a host. Hmm. Web site suggests looking at all of the test cases. Ok, look for test cases. Nope. No test cases, no test directory no test files.

Spent better half of day looking for something to show an example of a simple connection.
Found a scrap where you can specify a port forward. Ok, close, but perhaps not enough?

What I'm trying to do:

Connect to a cellular modem that's attached to my PC and get configuration info. I can do this through Putty without a hitch. Want to add code to my app to do this automatically.


using (var client = new SshClient(IPAddress, "admin", Password))
client.HostKeyReceived += client_HostKeyReceived;
var sshCMD = client.CreateCommand("get"); // modem specific command to send config data
sshCMD.Execute(); // Exception here - see note below
var myres = sshCMD.Result;

Error received: "Offset and length were out of bounds for the array or count is greater than the number of elements from index to the end of the source collection."

  1. Thinking perhaps this is some kind of buffer overflow, I specified a command that would normally only return a small number of characters (<30) and it errors the same.
  2. Looked for the "test" cases across the web, and there's a few bits here and there, but none of the code shows the basic flow of connect->command->result

Found the test directory and samples after re-downloading the zip. Something must have happened between download and unzip? Unfortunately, the code still fails regardless of command and method - the RunComand() method fails the same. When I stepped through the code, everything including the encryption and sending of data across the channel is working - it's failing on a WaitHandle switch statement (case 0) .
May 2, 2014 at 9:00 AM
You're right stating currently there's no artifact containing the tests available directly on the Downloads page.
However, you can easily download the full sources of a given release using the following procedure:
  1. Navigate to the Downloads page.
  2. Click the desired version in the OTHER DOWNLOADS panel.
  3. Click the link next to the "Change Set" label (eg. 35216 for the 2014.4.6-beta1 release).
  4. Click the Download button.
This will be automatically generate a zip file containing all the sources of the release you selected.

As for the doc remark:
There's a "SshNet Help" artifact available on the Downloads page.
This is a HTML Help file containing the API docs.
These docs also include small examples.

Can you provide the full stack trace for the error you received ?