writing data over channel to server problem

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

writing data over channel to server problem

Post by snorkel » Wed 05 Nov 2008 21:14

I have a server and client setup and running.
the client has a sshclient and channel component on it, both connect fine,
When I do this on the client:

command_chan.WriteString('test'+#13#10);

The server gets the string ok, but then..

The server raises this error:
"Format of server version is invalid"

Any idea what I am doing wrong?

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 06 Nov 2008 12:21

Please, give a more detailed description of your application. Where SSH channel is connected?
It is possible that the error is arised by the end server and not SSH server.

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Post by snorkel » Thu 06 Nov 2008 17:45

Dimon wrote:Please, give a more detailed description of your application. Where SSH channel is connected?
It is possible that the error is arised by the end server and not SSH server.
the channel is connected to a securebridge ssh server I setup.
On the server I have the ondatafromclient event set to grab any strings sent from the client and it gets the string, then raises that error.
If I send the client version string(command_chan.WriteString('SSH-2.0-Devart-1.0'+#13#10); instead it does not raise the error, but what's thoe point if I can only send a version string. It's checking every string sent to see if it's a version string and compares it to the version of the server.

The error on the server is being raised in:
procedure TProtocolNegotiationHandler.VerifyVersion(const Vers: string);

Whatever I send to the server over the channel in direct mode gets funnelled through that procedure and raises a error if the string is not SSH-2.0-Devart-1.0

You should not have to send the version string each time you write data to a connected channel.

This is with the latest Version on D2007 by the way, it also occured with the last version.

Here is a example client and server that demos the problem:
http://www.milwaukeesoft.com/example.zip

run the server (ignore the buttons), then run the client and push the button to write a string to the server. Server will display the string in a messagebox and then raises that error.

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Post by snorkel » Mon 10 Nov 2008 15:28

Anyone have any idea on this? is it a bug, or am I just doing something wrong?

Thanks,

Snorkel

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 13 Nov 2008 13:37

The problem is that you create command_chan which tries to connect to SSH server as SSH client.
To create channel only for data exchanging with SSH server you should set Direct to True in the TScSSHServer.BeforeChannelConnect event handler.

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Post by snorkel » Fri 14 Nov 2008 18:12

Dimon wrote:The problem is that you create command_chan which tries to connect to SSH server as SSH client.
To create channel only for data exchanging with SSH server you should set Direct to True in the TScSSHServer.BeforeChannelConnect event handler.
ah, I didn't know that.
so how do i tell which channel is which in that event?

You should do a little demo on how to use the direct mode.

Thanks,

Snorkel

snorkel
Posts: 384
Joined: Tue 08 Aug 2006 15:10
Location: Milwaukee WI USA

Post by snorkel » Fri 14 Nov 2008 18:20

snorkel wrote:
Dimon wrote:The problem is that you create command_chan which tries to connect to SSH server as SSH client.
To create channel only for data exchanging with SSH server you should set Direct to True in the TScSSHServer.BeforeChannelConnect event handler.
I added this to the event, which I think should work:
direct:= channelinfo.Direct;

but I still get that error about the version.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Mon 17 Nov 2008 08:59

The ChannelInfo.Direct property is not connected with the TScSSHChannel.Direct property and it is connnected only with server settings. Therefore it can be set only in the TScSSHServer.BeforeChannelConnect event handler. You can set it to True checking the DestPort property, like this:

Code: Select all

if ChannelInfo.DestPort = (Sender as TScSSHServer).Port then
  Direct := True;

sbrvar
Posts: 1
Joined: Wed 10 Jan 2007 20:52

Post by sbrvar » Mon 04 Oct 2010 23:11

Dimon wrote:The ChannelInfo.Direct property is not connected with the TScSSHChannel.Direct property and it is connnected only with server settings. Therefore it can be set only in the TScSSHServer.BeforeChannelConnect event handler. You can set it to True checking the DestPort property, like this:

Code: Select all

if ChannelInfo.DestPort = (Sender as TScSSHServer).Port then
  Direct := True;
Isn't (Sender as TScSSHServer).Port always 22? How can the destination port of the channel be the same port?

What I'm trying to do is the following:

- I have log server running behind the firewall, listening to port 514
- opened SSH tunnel and all working ok for accessing SQL DB via SDAC
- I'd now like to send log message to log server to port 514 through SSH tunnel

Port forwarding doesn't seem to work in this case, so I assume I have to do something with "Direct" but really can't seem to reach the log server :(

Any ideas?

Kind regards,
Sabina

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 05 Oct 2010 12:11

Setting the ChannelInfo.Direct property to True means that the information received from the SSH client is not passed ahead automatically. In this case the input information must be handled in a handler of the OnDataFromClient event. In this case the channel destination port is used for channel identification, and it doesn't mean that SSH server will connect to itself.

In your case the better way is to use local port forwarding. Please give a more detailed description of the problem that arises in this case.

Post Reply