SSH.NET and ASP.NET - WeOnlyDo Discussion board

SSH.NET and ASP.NET (wodSSH / wodSSH.NET)

by jgordon, Saturday, August 21, 2004, 01:37 (7424 days ago)

I noticed that all the sample apps provided are for Windows Applications. Will the component work in an ASP.Net app?

And which methods would you recommend to use to send commands to the ssh server?

I have been using the execute method and just can't seem to get it to work. I am returning to a textbox the prompt(eg. [root@hostname root]#) but the app times out when I try to execute a command.

here's my code inside the execute function:
.Login = username
.Password = password
.Port = 22
.Encryption = WeOnlyDo.Client.SSH.EncryptionMethods.Auto
.Protocol = WeOnlyDo.Client.SSH.SupportedProtocols.SSHAuto
.Blocking = True
.Connect(txtHostIP.Text)
.Prompt = #
.Execute(ls -al/r/n)

Your insight would be greatly appreciated.

Re: SSH.NET and ASP.NET

by wodSupport, Saturday, August 21, 2004, 02:07 (7424 days ago) @ jgordon

Jgordon,

here's what you should try. If you're 100 sure that # is the remote prompt, make sure you first consume all that is initially sent by the server, then send your command and read output, something like this:
[code]...
ssh.Connect
ssh.Waitfor('#')
Response.Write ssh.Execute( ls -al\n , # )
ssh.Disconnect[/code]
make sure you don't send CRLF but only LF sequence - most UNIX servers prefer only LF to be sent.

Can you try above and let me know how it goes?

Regards.

Re: SSH.NET and ASP.NET

by jgordon, Saturday, August 21, 2004, 02:31 (7424 days ago) @ wodSupport

I used the code you just gave me, debugged the app, and it timed out at the .WaitFor( # ) statement.

The DataReceivedEvent is delivering this to my textbox:
Last login: Fri Aug 20 10:03:17 2004 from jgordon2k3.mydomain.com

[root@mycomputer root]#

The exception I am getting is:
Timeout occurred due to inactivity

What do you think?

Re: SSH.NET and ASP.NET

by wodSupport, Saturday, August 21, 2004, 09:37 (7424 days ago) @ jgordon

Do you consume data from within DataReceived event? If you do, then there's nothing left for WaitFor. Perhaps this is the reason timeout expires?