EldoS | Feel safer!

Software components for data protection, secure storage and transfer

SFTP (Public key authentication) using TElIdSftpClient class

Posted: 09/09/2013 09:54:45
by Egon Schulz (Basic support level)
Joined: 09/09/2013
Posts: 2


In my project i try to integrate secure ftp file transfer using private/public key authentication.

My developement surrounding:
- Delphi 2009 Professional
- Windows XP Professional
- Latest available SecureBlackbox demo package installed without any problems.
- Indy component suite

I test the demo project "IndySftpDemo.dpr" in the folder
which shows a solution based on the class "TElIdSftpClient" which has an interface similiar to the class "TIdFtp" which is part of the Indy component suite. The demo project has compiled without problems.

In the form "Connection properties" ("ConnPropsForm.pas") i entered the connetion data to the ftp server. In the
edit field "Private key file for PUBLICKEY authentication type" i entered the path to a passphrase encoded private key file generated with the tool "PuttyGen.exe". The public part of this file is stored to the .ssh folder the server provider told me use for public key storage. In the source code of the method "TfrmMain.Connect" ("MainForm.pas") i made the following changes:

key.KeyFormat := kfPuTTY;
if .. and (Key.LoadPrivateKey(frmConnProps.edPrivateKey.Text, <Passphrase>) = 0) then

Running the demo it happens this:
- the method "Key.LoadPrivateKey()" returns 0 and seemed to accept the private key data.
- after calling the method "FSFTPClient.Connect" the exception "Sftp connection failed with message .." is thrown.

I have made an reference connect with the program "WinScp.exe" using the same private key file and a connection to the server was established.

My question:
- What causes the reported exception.

kind regards
Posted: 09/09/2013 10:03:50
by Eugene Mayevski (Team)

Thank you for detailed description of the problem.

1) Please try to load and run SimpleSFTPDemo from <SecureBlackbox>\Samples\Delphi\SFTPBlackbox\Client folder and see if it shows the same error. We use that demo for all tests and it has a log where some details about the connection are written.

2) It's important for us to see the exact exception message and also Class Name and ErrorCode property.

Sincerely yours
Eugene Mayevski
Posted: 09/09/2013 15:34:25
by Egon Schulz (Basic support level)
Joined: 09/09/2013
Posts: 2


i prepared the project "SimpleSFTPDemo.dpr" in the same way as the project "IndySftpDemo.dpr".
I just allow authentication type "SSH_AUTH_TYPE_PUBLICKEY". The method Key.LoadPrivateKey(<Private key file>,<passphrase>) returns 0 and the value "SSH_AUTH_TYPE_PUBLICKEY" is stored in property "TElSimpleSFTPClient.AuthenticationTypes". Here the messages after calling method "TElSimpleSFTPClient.Open":

Ok>> Server key [..] received
Err>> Authentication type [2] failed
Err>> Error 114
Err>> Sftp connection failed with message [Connection lost (error code is 10058)]
Err>> If you have ensured that all connection parameters are correct and you still can't connect,
Err>> please contact EldoS support as described on http://www.eldos.com/sbb/support.php
Err>> Remember to provide details about the error that happened.
Err>> Server software identified itself as: mod_sftp/0.9.7

Kind regards
Posted: 09/10/2013 00:45:37
by Vsevolod Ievgiienko (Team)

Please try to follow the steps described in this article: https://www.eldos.com/security/articles/4796.php
Posted: 09/10/2013 00:51:04
by Eugene Mayevski (Team)

I'll move the ticket to Helpdesk for investigation.

Sincerely yours
Eugene Mayevski



Topic viewed 2923 times

Number of guests: 1, registered members: 0, in total hidden: 0


Back to top

As of July 15, 2016 EldoS business operates as a division of /n software, inc. For more information, please read the announcement.

Got it!