Execute Remote Application using SSH - WeOnlyDo Discussion board

Execute Remote Application using SSH (General questions)

by KG, Thursday, August 18, 2005, 23:30 (7036 days ago)

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

by wodSupport, Thursday, August 18, 2005, 23:46 (7036 days ago) @ 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

by KG, Friday, August 19, 2005, 00:42 (7036 days ago) @ wodSupport

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

by wodSupport, Friday, August 19, 2005, 00:45 (7036 days ago) @ 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

by KG, Friday, August 19, 2005, 02:05 (7036 days ago) @ wodSupport

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

by KG, Friday, August 19, 2005, 05:02 (7035 days ago) @ KG

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,
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

by wodSupport, Friday, August 19, 2005, 08:16 (7035 days ago) @ KG

That's windows server? Try setting AllocatePty = False.

Re: Execute Remote Application using SSH

by KG, Friday, August 19, 2005, 15:27 (7035 days ago) @ wodSupport

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

by KG, Friday, August 19, 2005, 15:29 (7035 days ago) @ KG

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

by wodSupport, Friday, August 19, 2005, 15:32 (7035 days ago) @ KG

Did AllocatePty=False help?

Re: Execute Remote Application using SSH

by KG, Friday, August 19, 2005, 15:50 (7035 days ago) @ wodSupport

No it did not help.

Did AllocatePty=False help?

Re: Execute Remote Application using SSH

by KG, Friday, August 19, 2005, 16:58 (7035 days ago) @ KG

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

by wodSupport, Friday, August 19, 2005, 17:24 (7035 days ago) @ KG

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

by KG, Friday, August 19, 2005, 17:29 (7035 days ago) @ wodSupport

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

by wodSupport, Friday, August 19, 2005, 17:31 (7035 days ago) @ KG

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

by wodSupport, Tuesday, August 30, 2005, 01:57 (7025 days ago) @ wodSupport

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

by KG, Tuesday, August 30, 2005, 22:36 (7024 days ago) @ wodSupport

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