This project is read-only.

SSH.NET

Oct 11, 2014 at 6:43 PM
I'm using sshnet for the first time and have a question. I use the following code to connect

using (var client = new SshClient("<site>", port, "<uid>", "<pw>"))
        {
            client.Connect();
            client.RunCommand("list");
            client.Disconnect();
        }

When I invoke the runcommand method, I receive a message that "client is not connected". When I check the client.IsConnected and client.IsAuthenticated attribute, both come back as true. Can someone point me in the right direction? All I'm trying to do is download and upload several files.

Thank you.
Coordinator
Oct 12, 2014 at 7:09 PM
I'm not able to reproduce this issue.
Please post the complete stacktrace.

What SSH server are you using, and which version of SSH.NET ?
Oct 13, 2014 at 12:24 AM
Thank you for responding. Here is the stack trace
Renci.SshNet.dll!Renci.SshNet.Session.WaitOnHandle(System.Threading.WaitHandle waitHandle) Line 717 C#
Renci.SshNet.dll!Renci.SshNet.Channels.Channel.WaitOnHandle(System.Threading.WaitHandle waitHandle) Line 487 + 0x10 bytes   C#
Renci.SshNet.dll!Renci.SshNet.Channels.ChannelSession.SendExecRequest(string command) Line 176 + 0xe bytes  C#
Renci.SshNet.dll!Renci.SshNet.SshCommand.BeginExecute(System.AsyncCallback callback, object state) Line 243 + 0x21 bytes    C#
Renci.SshNet.dll!Renci.SshNet.SshCommand.Execute() Line 319 + 0x12 bytes    C#
Renci.SshNet.dll!Renci.SshNet.SshClient.RunCommand(string commandText) Line 237 + 0xa bytes C#
TestWrapper.exe!TestWrapper.Program.sftp() Line 459 + 0x10 bytes    C#
TestWrapper.exe!TestWrapper.Program.Main(string[] args) Line 100 + 0x5 bytes    C#


The SSH server I am trying to invoke is
"SSH-2.0-IBM Sterling Connect:Enterprise for UNIX2.5.00"

I seem to be able to connect but cannot invoke commands.
Coordinator
Nov 4, 2014 at 7:50 PM
What version of SSH.NET are you using ?
Can you verify whether SshClient.IsConnect is still true after the exception ?

Also try subscribing to the Exception event to learn more on the reason why the connection was dropped:
            using (var client = new SftpClient(...))
            {
                client.ErrorOccurred += (sender, args) => Console.WriteLine(args.Exception);
                client.Connect();
                ...
            }
Coordinator
Nov 22, 2014 at 5:07 PM
@Dann055:
Have you made any progress on this ?
Jun 7, 2015 at 1:38 PM
Hey,

i also get the same error when i try to run a command and i'm very new to programming, but i need to fix the problem!

i'm using version: 2014.4.6-beta2

did you fix the problem?
Jun 7, 2015 at 4:02 PM
if found out that ssh.net really don't apply to a ssh session
using (var client = new SshClient(comboBox1.Text, username.Text, password.Text))
            {
                client.Connect();
                if (client.IsConnected)
                {
                    client.RunCommand("system reboot");
                    client.Disconnect();
                }
but it says connected and run the command