writing data over channel to server problem
writing data over channel to server problem
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?
			
									
									
						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?
the channel is connected to a securebridge ssh server I setup.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.
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.
ah, I didn't know that.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.
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
I added this to the event, which I think should work: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.
direct:= channelinfo.Direct;
but I still get that error about the version.
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?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;
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
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.
			
									
									
						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.