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
Problem using SSHClient and SSHChannel
-
- Devart Team
- Posts: 271
- Joined: Wed 23 Jan 2013 11:21
Re: Problem using SSHClient and SSHChannel
Hello.
Try connecting to the SSH server using SSHClient Demo of SecureBridge.
Try connecting to the SSH server using SSHClient Demo of SecureBridge.
Re: Problem using SSHClient and SSHChannel
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.
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.
-
- Devart Team
- Posts: 271
- Joined: Wed 23 Jan 2013 11:21
Re: Problem using SSHClient and SSHChannel
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.
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.
Re: Problem using SSHClient and SSHChannel
Thanks for the reply.
I have successfully managed local ports offset in order to be able to run several applications at the same time.
I have successfully managed local ports offset in order to be able to run several applications at the same time.
-
- Devart Team
- Posts: 271
- Joined: Wed 23 Jan 2013 11:21
Re: Problem using SSHClient and SSHChannel
If any other questions come up, please contact us.