EldoS | Feel safer!

Software components for data protection, secure storage and transfer

SimpleSSHClient.OnSendCommandRequest not firing

Posted: 06/09/2010 18:26:07
by Vincent Parrett (Standard support level)
Joined: 01/17/2008
Posts: 20

One problem with that: OnCloseConnection is never fired, so the loop is infinite.

I've added some extra event handling, here is the output:
OnKeyValidate fired
OnAuthenticationSuccess fired
OnSendCommandRequest fired
Client is not active
echo foo:
Using ServerSoftware: OpenSSH_5.2

And the code:
       private static TElSimpleSSHClient client = new TElSimpleSSHClient();
        private static bool isConnected;

        static void Main(string[] args)
            TElSSHMemoryKeyStorage mks = new TElSSHMemoryKeyStorage();
            client.KeyStorage = mks;

            client.Username = "user";
            client.Password = "password";
            client.Address = "";
            client.AuthenticationTypes = SBSSHConstants.Unit.SSH_AUTH_TYPE_PASSWORD;
            client.RequestTerminal = false;

            client.OnKeyValidate += new SBSSHCommon.TSSHKeyValidateEvent(client_OnKeyValidate);
            client.OnSendCommandRequest += new SBSSHCommon.TSSHCommandExecutionEvent(client_OnSendCommandRequest);
            client.OnError += new SBSSHCommon.TSSHErrorEvent(client_OnError);
            client.OnCloseConnection += new SBSSHCommon.TSSHCloseConnectionEvent(client_OnCloseConnection);
            client.OnAuthenticationSuccess += new SBUtils.TNotifyEvent(client_OnAuthenticationSuccess);
            client.Commands.Add("echo foo");
            client.Commands.Add("echo bar");

            Console.WriteLine("Using ServerSoftware: " + client.ServerSoftwareName);


        static void client_OnAuthenticationSuccess(object Sender)
            Console.WriteLine("OnAuthenticationSuccess fired");

        static void client_OnCloseConnection(object Sender)
            Console.WriteLine("OnCloseConnection fired");

        static void client_OnError(object Sender, int ErrorCode)
            Console.WriteLine("OnError fired");
            Console.WriteLine("Error: " + ErrorCode);

        static void client_OnSendCommandRequest(object Sender, string Command, int CommandIdx)
            Console.WriteLine("OnSendCommandRequest fired");
            Console.WriteLine(client.Active ? "Client is active" : "Client is not active");
            string s = "";
            while (client.CanReceive(1000))
                s += client.ReceiveText();

            Console.WriteLine(Command + ": " + s);


        static void client_OnKeyValidate(object Sender, TElSSHKey ServerKey, ref bool Validate)
            Console.WriteLine("OnKeyValidate fired");
            Validate = true;            

As you can see, OnCloseConnection is never fired, but client.Active is false in OnSendCommandRequest.

Just be sure it's not a config issue, I set up a fresh SSH server (using DamnSmallLinux). ServerSoftwareName is OpenSSH_3.6.1p2 Debian 1:3.6.1p2-9. The problem still exists. Can you replicate this problem on your servers?




Topic viewed 3413 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!