Use storage to store public server key, and private key when setting the SSH client. Private key is used in case of using the authentication method by key.

 

Storage setup

Place the TScFileStorage or TScRegStorage component onto the form.
Specify the path to be used to store information about keys in the Path / KeyPath property
It is required to obtain server public key in order to authenticate the server. There are two ways to obtain this key:
1.The key can be previously obtained from the server as described in the Keys transferring topic.
2.Upon the first connect to the server you receive its public key that has to be stored in the storage for the future use to authenticate the server. However, in this case the key is passed through the unprotected channel and can be substituted by a malefactor.
Add obtained key to the storage:
1.Open the component editor of the storage component by double click on the component and select the Keys tab.
2.Add a new key by pressing the New button.
3.Type the key name.
4.Import information from the obtained file by using the "Import from..." button.

 

If the authentication by a key is used, it is required to create the user key:

1.Open the component editor of the storage component by double click on the component and select the Keys tab.
2.Pressing the New button and type the key name.
3.Choose the algorithm to use and the needed key length.
4.Push the Generate button to generate a new key.
5.Export the public key and pass it to the server in order to the server be able to authenticate the client.

 

SSH client setup

Place the TScSSHClient component onto the form.
Select a storage object in the KeyStorage property.
Specify the host name on which the SSH server is located in the HostName property.
Specify the server public key in the HostKeyName property.
Specify the user name in the User property.
Choose authentication algorithm in the Authentication property.
If authentication by password is used, specify password in the Password property.
If authentication by key is used, specify the private key name in the PrivateKeyName property. The HostName value is used as a default key name. You can find steps to create a new key above in this topic.
Establish connection to the server setting the Connected property to True.

You should create an SSH channel in order to exchange data with a remote host.

 

SSH channel setup

Place the TScSSHChannel component onto the form.
Select an SSH client in the Client property.
Specify the host name in DestHost and the TCP/IP port number in DestPort to which the connection should be established.
Specify the port number in SourcePort, data from which will be forwarded to the remote host to which the connection is established.
Open the SSH channel setting the Connected property to True.

 

Random numbers generating

When establishing a connection to the SSH server, random numbers for creating session keys are generated. These keys will be used in the data encryption algorithms. For getting random numbers, pseudo random number generators are used. Before using the pseudo random number generator, you should initialize it, by setting a start seed value. This seed value can be obtained in different ways: using processor step counter, sound card noise, information of random mouse movements, or pressure of keyboard keys. However, the first two ways is not reliable.

One of such ways is implemented in the SSHClient demo.

When using the SecureBridge component library, you should pass a sequence of the random values to the Randomize method of the global Random object.

SecureBridge Components, Copyright © 2007-2024 Devart. All Rights Reserved. Provide Feedback Visit Forum Request Support