Problem using SSHClient and SSHChannel

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
RDTelecom
Posts: 14
Joined: Mon 26 Aug 2013 13:52

Problem using SSHClient and SSHChannel

Post by RDTelecom » Mon 26 Aug 2013 13:59

Hello,

I have an application which communicates with an equipment using TClientSocket class on 3 different ports 5000, 5001, 5002.
The application can be instantiated several times to connect to other similar equipments still using the same ports but a different IP address.

I want to secure communication between this application and the equipments with SSH while keeping existing behavior with equipment not having SSH activated.
SSH is already implemented on some equipments, there is no server centralizing access to the equipments.

I am using C++ Builder 2007 IDE and SecureBridge v5.5.1

Initialization of SSHClient and SSHChannel are done as follows:

_pSSHClient->HostName = aIpAddress;
_pSSHClient->HostKeyName = _keyFileName;
_pSSHClient->Port = 22;
_pSSHClient->User = login;
_pSSHClient->Authentication = atPassword;

_pSSHChannel->SourcePort = 22;
_pSSHChannel->DestPort = 5000;
_pSSHChannel->DestHost = _pSSHClient->HostName;

I have the OnServerKeyValidate() event called but I get the exception "Host key not verified" due to an empty NewServerKey parameter.

Am I following the right steps to implement the way I want the application to behave ?
Any idea why I have this exception knowing that using Tera Term client I get the server fingerprint witout error and am able to connect to the equipment ?

Thanks

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Problem using SSHClient and SSHChannel

Post by DemetrionQ » Fri 30 Aug 2013 15:41

Hello.

Try connecting to the SSH server using SSHClient Demo of SecureBridge.

RDTelecom
Posts: 14
Joined: Mon 26 Aug 2013 13:52

Re: Problem using SSHClient and SSHChannel

Post by RDTelecom » Fri 06 Sep 2013 12:19

Thanks,

The problem was solved correcting the following:
- the Connect method needed to be called on SSHClient instance first then on the SSHChannel instance.
- there was some mixing between SourcePort and DestPort on the SSHChannel instance.

Can you confirm the following:
1) a SSHChannel instance is needded for each port used simultaneously (though using the same SSHClient instance)
2) in each application instance a different SourcePort must be used for SSHChannel instances since SourceHost is always 'localhost'. Though the port would overlapp and channel connection fail.

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Problem using SSHClient and SSHChannel

Post by DemetrionQ » Mon 09 Sep 2013 15:57

Hello.

1) When using several listening ports simultaneously (SourcePort), a TSSHChannel instance should be created for each of them.
2) When using several applications with TSSHChannel (or several TSSHChannel instances in one application), each TSSHChannel instance should have a unique TSSHChannel.SourcePort property value, since every TSSHChannel instance opens a socket for listening via the port, specified in the TSSHChannel.SourcePort property.

RDTelecom
Posts: 14
Joined: Mon 26 Aug 2013 13:52

Re: Problem using SSHClient and SSHChannel

Post by RDTelecom » Tue 10 Sep 2013 08:33

Thanks for the reply.
I have successfully managed local ports offset in order to be able to run several applications at the same time.

DemetrionQ
Devart Team
Posts: 271
Joined: Wed 23 Jan 2013 11:21

Re: Problem using SSHClient and SSHChannel

Post by DemetrionQ » Tue 10 Sep 2013 08:54

If any other questions come up, please contact us.

Post Reply