Secure bridge using private key

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
fuandi
Posts: 6
Joined: Mon 26 Feb 2018 03:16

Secure bridge using private key

Post by fuandi » Mon 26 Feb 2018 04:26

Hi, i'm using securebridge trial with delphi seattle.

I'm trying to connect to sftp server using the demo (sftpclient), but I don't know how to use my private key.
I saw a selection in dropdownbox. Can i use my own private key (.ppk file) instead of the system generated ? how to do it ?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Secure bridge using private key

Post by ViktorV » Mon 26 Feb 2018 09:53

For SSH authentication, two different keys are used: server key and client key. The server key is used to authenticate the SSH server and is checked on the client. Its name is specified in the TScSSHClient.HostKeyName property.
The client key is used to authenticate the client and is checked on the SSH server. Its name is specified in the TScSSHClient.PrivateKeyName property. The private key contains a public key and this pair is one key.
Note that the SFTP server must be preconfigured to support public key authentication for your user. For more information on configuring the SFTP server, please refer to its documentation.

fuandi
Posts: 6
Joined: Mon 26 Feb 2018 03:16

Re: Secure bridge using private key

Post by fuandi » Tue 27 Feb 2018 01:35

the server is managed by other vendor, i need to connect to it and i only have username and private key .ppk file
how to do this ?

TScSSHClient.PrivateKeyName := 'C:\privatekey.ppk'

is this correct ?

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: Secure bridge using private key

Post by ViktorV » Tue 27 Feb 2018 10:37

If the SFTP server is configured for public key access, to solve your problem you can use the following recommendations:
- import your private key into the TScStorage successor in the designtime or runtime:
- set the TScSSHClient.Authentication property to atPublicKey;
- in the TScSSHClient.PrivateKeyName property, specify the name of the private key from TScStorage.
Example:

Code: Select all

procedure Connect;
var
Key: TScKey;
begin
Key: = TScKey.Create (ScFileStorage.Keys);
Key.KeyName: = 'key1';
Key.ImportFrom ('C:\privatekey.ppk');

ScSSHClient.Authentication: = atPublicKey;
ScSSHClient.KeyStorage: = ScFileStorage;
ScSSHClient.PrivateKeyName: = 'key1';
ScSSHClient.Connect;
end;

Post Reply