F-Secure SSH servers with EmulationType of color (General questions)
I am experiencing an issue connecting wodSSH.NET to F-Secure SSH servers (on Windows Server 2003) that use an EmulationType of color. When using color I receive a timeout on the WaitFor call to get a prompt after login:
[code]Trace.WriteLine(_sshClient.WaitFor(_sshPrompt, 15));[/code]
When I change that to stream my code works fine, but I need it to work with color also to conform to our standards
I am using a prompt of [code]regex:[$ #>]s?$[/code]
Any help is appreciated
[code]
public void Run()
{
_sshClient = new SSH();
_sshClient.AllocatePty = false;
_sshClient.LicenseKey = WOD_SSH_LicenseKey;
_sshClient.Hostname = _targetServer;
_sshClient.Login = _login;
_sshClient.Password = _password;
_sshClient.Protocol = SSH.SupportedProtocols.SSHAuto;
_sshClient.Blocking = true;
_sshClient.Timeout = 60;
_sshClient.DataReceivedEvent += new WeOnlyDo.Client.SSH.DataReceivedDelegate(_sshClient_DataReceivedEvent);
_sshClient.StateChangedEvent += new WeOnlyDo.Client.SSH.StateChangedDelegate(_sshClient_StateChangedEvent);
_sshClient.ShowStdErrorMessages = true;
Trace.WriteLine( Establishing connection );
_sshClient.Connect();
Trace.WriteLine( Waiting for connection extablished prompt );
Trace.WriteLine(_sshClient.WaitFor(_sshPrompt, 15));
Trace.WriteLine(_sshClient.Receive());
Trace.WriteLine( Starting commands );
string result = _sshClient.Execute( dir *.*
, _sshPrompt);
// Trace.WriteLine(result);
// result = _sshClient.Execute( cd ..
, _sshPrompt);
// Trace.WriteLine(result);
// Trace.WriteLine( Command 2 );
// result = _sshClient.Execute( dir *.*
, _sshPrompt);
// Trace.WriteLine(result);
// //Trace.WriteLine(ExecuteSSHCommand( CD \
, _sshPrompt));
// Trace.WriteLine(ExecuteSSHCommand( dir *.*
, _sshPrompt));
//Trace.WriteLine(ExecuteSSHCommand( RMDIR /S /Q + _executeLocation +
, _sshPrompt));
Trace.WriteLine( Completed );
_sshClient.Disconnect();
_sshClient.Dispose();
}
private void _sshClient_DataReceivedEvent(object Sender, WeOnlyDo.Client.SSH.DataReceivedArgs args)
{
Trace.WriteLine(DateTime.Now.ToString() + : + String.Format( Data Received Event: {0} bytes , args.BytesCount));
}
private void _sshClient_StateChangedEvent(object Sender, WeOnlyDo.Client.SSH.StateChangedArgs args)
{
Trace.WriteLine(String.Format( {0} : {1} , DateTime.Now, State Changed From:' + args.OldState + ' To: ' + args.NewState + ' ));
}
[/code]
Re: F-Secure SSH servers with EmulationType of col
Hi David,
The Timeout occurs because the component didn't receive the expected Prompt...
Can you check if the Prompt that you receive is actually the one that you set using the regex ?
Also, can you try connecting to your server using any other Client, like Putty... Can you show me sample of how your prompt looks like?
You could also try setting TerminalType Property to tty or std .
Regards,
Damba
Re: F-Secure SSH servers with EmulationType of col
- No text -
Re: F-Secure SSH servers with EmulationType of col
Hi Drkd,
In order to solve this issue, we will need to do some tests. I hope you don't mind.
First thing i need to ask you is to add a few lines to your codes, right after the Connect Method is called.
You can insert:
--------------------------------------
Trace.WriteLine(_sshClient.Receive());
Trace.WriteLine(_sshClient.Receive());
Trace.WriteLine(_sshClient.Receive());
--------------------------------------
The point of this is to see what exactly you receive from your server although the timeout will occur again, but we will have the exact look of your prompt. Please send us with the string as you received it from the server.
If we accomplish that, we will probably be able to solve this problem by setting the Prompt to the exact value as sent from the server.
One more thing that would help us a lot to solve the problem is if you could download our ActiveX version of wodSSH Component, and try connecting to your server with StripANSI Property set to True .
The reason for this is to see if that would solve the problem. wodSSH.Net doesn't currently have that Property integrated, but if this does the work, we would insert it into .Net version too. This Property removes any ANSI codes from the received data, which i believe could solve this.
Regards,
Damba
Re: F-Secure SSH servers with EmulationType of col
Damba. Here is what I get back from the Receive() call. It does not paste well, but I think you get the idea.
[code]
_[?1000h_[37;40m_[21m_[2J_[1;1H_[37;40m_[21mMicrosoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
C:\Documents and Settings\o003303>
_[4;35H
[/code]
I tried out the ActiveX control and here is the results with StripANSI set to false:
[code]
[?1000h[37;40m[21m[2J[1;1H[37;40m[21mMicrosoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
C:\Documents and Settings\o003303>
[/code]
Here it is with StripANSI set to true:
[code]
Microsoft Windows [Version 5.2.3790]
(C) Copyright 1985-2003 Microsoft Corp.
C:\Documents and Settings\o003303>
[/code]
Re: F-Secure SSH servers with EmulationType of col
Hi David,
Please try to use WaitFor Mathod on this way:
_sshClient.WaitFor( C:\Documents and Settings\o003303> )
Let us know how it goes.
Regards,
Drazen
Re: F-Secure SSH servers with EmulationType of col
Hello Drazen. I tested with my original code since your post was not specific. It will successfully connect if I wait for that specific value you suggested of C:Documents and Settingso003303> . The problem is that the value in question will change because it is a current path. The prompt value I am using, regex:[$ #>]s?$, is based on a recommendation I received from a WOD Soft support person on another thread. And this has worked quite well with other EmulationType settings of raw and stream within F-Secure server. The testing that Ramba had me do with the StripANSI of the ActiveX version seems to be the best solution here instead of my need to interpret all the garbage characters coming that I am getting. Please advise.
Re: F-Secure SSH servers with EmulationType of col
David,
Please try my code:
-----------------------------------
ssh1 = New WeOnlyDo.Client.SSH
ssh1.Hostname = your_hostname
ssh1.Login = your_login
ssh1.Password = your_password
ssh1.Blocking = True
ssh1.Protocol = WeOnlyDo.Client.SSH.SupportedProtocols.SSHAuto
ssh1.AllocatePty = False
ssh1.Connect()
ssh1.WaitFor( regex:[$ #>]s?$ )
ssh1.DataReady = 0
TextBox1.Text = ssh1.Execute( dir + vbLf, ( regex:[$ #>]s?$ ))
-----------------------------------
If problem persist, can we somehow connect to your server and duplicate your problem, is this possible?
You can send private information to techsupport@weonlydo.com (hostname, login, password).
Let us know how it goes.
Regards,
Drazen
Re: F-Secure SSH servers with EmulationType of col
Using your code works for an EmulationType of stream but fails for an EmulationType of color, just as my code did. Using color I get a timeout on the WaitFor call. Using stream I get the following output:
[code]
d[Kdi[Kdir[Kdir
Volume in drive C is C_Drive
Volume Serial Number is 24BB-4860
Directory of C:\Documents and Settings\o003303
09/01/2006 11:03 AM <DIR> .
09/01/2006 11:03 AM <DIR> ..
10/16/2006 10:31 AM <DIR> Desktop
08/31/2006 10:03 AM <DIR> Favorites
09/15/2006 06:06 PM <DIR> My Documents
06/23/2006 06:56 AM <DIR> Start Menu
06/23/2006 07:00 AM 0 Sti_Trace.log
1 File(s) 0 bytes
6 Dir(s) 8,878,514,176 bytes free
[/code]
If problem persist, can we somehow connect to your server and duplicate your problem, is this possible?
Unfortunately this is not an option for us. Have you see these results for EmulationType of color with F-Secure Server in you lab testing? Please advise.
-DRKD
Re: F-Secure SSH servers with EmulationType of col
David,
Can you get it to work as you want if you use wodSSH ActiveX component?
What did you done in ActiveX version of wodSSH. Just set StripANSI = True and it worked?
Drazen
Re: F-Secure SSH servers with EmulationType of col
Drazen,
As stated above when working with Damba, when I tested with the ssh ActiveX control and set the StripANSI to true, it worked for an EmulationType of color. Is this something that can be added to the ssh.net version?
-DRKD
Re: F-Secure SSH servers with EmulationType of col
David,
Please try my code:
-----------------------------------------
ssh1 = New WeOnlyDo.Client.SSH
ssh1.Hostname = your_hostname
ssh1.Login = your_login
ssh1.Password = your_password
ssh1.Blocking = True
ssh1.Protocol = WeOnlyDo.Client.SSH.SupportedProtocols.SSHAuto
ssh1.AllocatePty = False
ssh1.Connect()
ssh1.WaitFor( regex:[$ #>]*$ )
ssh1.DataReady = 0
Console.Write(ssh1.Execute( dir + vbCrLf, ( regex:[$ #>]*$ )))
-----------------------------------------
As you can see I use for prompt regular expression: regex:[$ #>]*$
Let us know how it goes.
Drazen