EldoS | Feel safer!

Software components for data protection, secure storage and transfer

SimpleSSHClient.OnSendCommandRequest not firing

Also by EldoS: BizCrypto
Components for BizTalk® and SQL Server® Integration Services that let you securely store and transfer information in your business automation solutions.
#13637
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:
Quote
OnKeyValidate fired
OnAuthenticationSuccess fired
OnSendCommandRequest fired
Client is not active
echo foo:
Using ServerSoftware: OpenSSH_5.2


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

        static void Main(string[] args)
        {
            SBUtils.Unit.SetLicenseKey("key");
            TElSSHMemoryKeyStorage mks = new TElSSHMemoryKeyStorage();
            client.KeyStorage = mks;

            client.Username = "user";
            client.Password = "password";
            client.Address = "10.0.0.113";
            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");
            
            client.Open();

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

            Console.ReadLine();
        }

        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?

Cheers

Reply

Statistics

Topic viewed 3130 times

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




|

Back to top

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

Got it!