Execute Remote Application using SSH (General questions)
Hello,
I would like to execute a remote application using SSH.NET, can some one let me know on how to achieve the same?
Is it possible to know if the application executed successfully or not on the remote server.
Thanks,
KG
In the sample code there is mention of
Ssh1.ConnectedEvent += new WeOnlyDo.Client.SSH.ConnectedDelegate(Ssh1_Connected);
What is the Ssh1_Connected expecting as arugument any sample will be of great help.
Re: Execute Remote Application using SSH
KG,
Hello,
I would like to execute a remote application using SSH.NET, can some one let me know on how to achieve the same?
I think easiest way would be to set Command property. Once connected, wodSSH.NET will execute whatever you put in Command property. When your command ends, wodSSH will disconnect.
Is it possible to know if the application executed successfully or not on the remote server.
Currently you can call Receive method to see what response it receives. In few days we will add ExitStatus property so you will be able to receive that info, if provided by your command.
In the sample code there is mention of
Ssh1.ConnectedEvent += new WeOnlyDo.Client.SSH.ConnectedDelegate(Ssh1_Connected);
What is the Ssh1_Connected expecting as arugument any sample will be of great help.
There are few samples provided with wodSSH.NET, try them out. All of them have Connected event, so you can see how it is declared.
Regards.
Re: Execute Remote Application using SSH
I tried the following code and it didn't create a folder as expected anything wrong?
SSH Ssh1 = new SSH(); // Initialize new instance
Ssh1.Login = UserID ; // Set your login/username
Ssh1.Password = password ; // Set your password
Ssh1.Encryption = WeOnlyDo.Client.SSH.EncryptionMethods.Auto; // Any SSH.SupportedProtocols.SSH1;
Ssh1.Command = mkdir c:\temp ;
Ssh1.LicenseKey = XYZ ;
Ssh1.Connect( cigvirtusa3 );
Thanks,
KG
KG,
Hello,
I would like to execute a remote application using SSH.NET, can some one let me know on how to achieve the same?I think easiest way would be to set Command property. Once connected, wodSSH.NET will execute whatever you put in Command property. When your command ends, wodSSH will disconnect.
Is it possible to know if the application executed successfully or not on the remote server.
Currently you can call Receive method to see what response it receives. In few days we will add ExitStatus property so you will be able to receive that info, if provided by your command.
In the sample code there is mention of
Ssh1.ConnectedEvent += new WeOnlyDo.Client.SSH.ConnectedDelegate(Ssh1_Connected);
What is the Ssh1_Connected expecting as arugument any sample will be of great help.There are few samples provided with wodSSH.NET, try them out. All of them have Connected event, so you can see how it is declared.
Regards.
Re: Execute Remote Application using SSH
KG,
in your code try setting Ssh1.Blocking = True, otherwise your instance if destroyed immediately when your function exits, so it doesn't give enough time for component to complete the operation. Blocking should make it work for you.
Re: Execute Remote Application using SSH
Now I am getting this error. Could not obtain channel pty on remote server.
in the code I have added Ssh1.AllocatePty = false;
The Server was installed using default settings.
Thanks,
KG
KG,
in your code try setting Ssh1.Blocking = True, otherwise your instance if destroyed immediately when your function exits, so it doesn't give enough time for component to complete the operation. Blocking should make it work for you.
Re: Execute Remote Application using SSH
Yes, I have used that too.
Ssh1.Blocking = true;
Tahnks,
Karthik
Now I am getting this error. Could not obtain channel pty on remote server.
in the code I have added Ssh1.AllocatePty = false;
The Server was installed using default settings.
Thanks,
KGKG,
in your code try setting Ssh1.Blocking = True, otherwise your instance if destroyed immediately when your function exits, so it doesn't give enough time for component to complete the operation. Blocking should make it work for you.
Re: Execute Remote Application using SSH
That's windows server? Try setting AllocatePty = False.
Re: Execute Remote Application using SSH
Yes, Its a windows server.
Complete C# code
SSH Ssh1 = new SSH(); // Initialize new instance
Ssh1.Login = UserID ; // Set your login/username
Ssh1.Password = password ; // Set your password
Ssh1.Encryption = WeOnlyDo.Client.SSH.EncryptionMethods.Auto;
Ssh1.Protocol = SSH.SupportedProtocols.SSH2;
Ssh1.Command = mkdir c: emp ;
Ssh1.LicenseKey = XYZ ;
Ssh1.Blocking = true;
Ssh1.Port = 22;
Ssh1.AllocatePty = false;
Ssh1.Connect( cigvirtusa3 );
That's windows server? Try setting AllocatePty = False.
Re: Execute Remote Application using SSH
Correction in the Command.
Ssh1.Command = mkdir c:\temp ;
Yes, Its a windows server.
Complete C# code
SSH Ssh1 = new SSH(); // Initialize new instance
Ssh1.Login = UserID ; // Set your login/username
Ssh1.Password = password ; // Set your password
Ssh1.Encryption = WeOnlyDo.Client.SSH.EncryptionMethods.Auto;
Ssh1.Protocol = SSH.SupportedProtocols.SSH2;
Ssh1.Command = mkdir c: emp ;
Ssh1.LicenseKey = XYZ ;
Ssh1.Blocking = true;
Ssh1.Port = 22;
Ssh1.AllocatePty = false;
Ssh1.Connect( cigvirtusa3 );That's windows server? Try setting AllocatePty = False.
Re: Execute Remote Application using SSH
Did AllocatePty=False help?
Re: Execute Remote Application using SSH
No it did not help.
Did AllocatePty=False help?
Re: Execute Remote Application using SSH
In the server log I get this message.
The description for Event ID ( 0 ) in Source ( F-Secure SSH Server ) cannot be found. The local computer may not have the necessary registry information or message DLL files to display messages from a remote computer. You may be able to use the /AUXSOURCE= flag to retrieve this description; see Help and Support for details. The following information is part of the event: connection lost: 'Connection closed.'.
Its a windows 2003 server where the user Id has administrator access. Its not a domain controller.
Thanks,
Karthik
No it did not help.
Did AllocatePty=False help?
Re: Execute Remote Application using SSH
Hmm, in that case I have no more ideas. AllocatePty is made exactly for that purpose, and in all cases it did help. I can't know what's going on. Perhaps F-Secure has some logs that can say what happened?
Can you paste your full code?
Re: Execute Remote Application using SSH
Complete C# code
SSH Ssh1 = new SSH(); // Initialize new instance
Ssh1.Login = UserID ; // Set your login/username
Ssh1.Password = password ; // Set your password
Ssh1.Encryption = WeOnlyDo.Client.SSH.EncryptionMethods.Auto;
Ssh1.Protocol = SSH.SupportedProtocols.SSH2;
Ssh1.Command = mkdir c:\temp ;
Ssh1.LicenseKey = XYZ ;
Ssh1.Blocking = true;
Ssh1.Port = 22;
Ssh1.AllocatePty = false;
Ssh1.Connect( servername ); // Windows 2003 Server. Default F-Secure Server Installation.
Even the sample application does not work for the same server. Is it to something with windows firewall?
Thanks,
Karthik
Hmm, in that case I have no more ideas. AllocatePty is made exactly for that purpose, and in all cases it did help. I can't know what's going on. Perhaps F-Secure has some logs that can say what happened?
Can you paste your full code?
Re: Execute Remote Application using SSH
I don't think this is firewall issue.
I can install F-Secure on monday and try it out. Or you can give me access to that server for a test? If you can, please send details to techsupport@weonlydo.com
Re: Execute Remote Application using SSH
I tried it. I installed F-Secure version SSH-2.0-3.2.0 F-Secure SSH Windows NT Server to fresh Windows 2003 Standard Server. Code like this worked correctly: [code] WeOnlyDo.Client.SSH s = new WeOnlyDo.Client.SSH();
s.Hostname = 192.168.192.50 ;
s.Login = Administrator ;
s.Password = test ;
s.Blocking = true;
s.Connect();
[/code]I have no idea why you have problems, only thing that comes to my mind is to allow me to connect to your host to try it out live .
Regards,
Kreso
Re: Execute Remote Application using SSH
Thanks,
Its working now.
I removed the Port and AllocatePty properties and it started working.. !!!
KG
I tried it. I installed F-Secure version SSH-2.0-3.2.0 F-Secure SSH Windows NT Server to fresh Windows 2003 Standard Server. Code like this worked correctly: [code] WeOnlyDo.Client.SSH s = new WeOnlyDo.Client.SSH();
s.Hostname = 192.168.192.50 ;
s.Login = Administrator ;
s.Password = test ;
s.Blocking = true;
s.Connect();
[/code]I have no idea why you have problems, only thing that comes to my mind is to allow me to connect to your host to try it out live .Regards,
Kreso