EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How can I login with Passphrase automatically

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
Posted: 04/06/2009 10:25:56
by Daniel Kurz (Basic support level)
Joined: 04/06/2009
Posts: 4

Hello EldoS Team,

I wanna use TElSimpleSftpClient to logon SFTP and tranfer files in PGP-authentication.

Keys works fine with WinSCP. My passphrase there also.

Where or how can I fill the passphrase in my written programm using TElSimpleSftpClient. I have simply no idea where to fill in the Passphrase
to login without any users input.
Without passphrase my programm works fine with my SFTP using normal Login and password.
Which components do I need to login automatically with a passphrase?

Thanks an advance!

Sincerely yours,
Daniel Kurz
Posted: 04/06/2009 10:56:01
by Eugene Mayevski (Team)

Unfortunately I don't understand your idea. What is "passphrase" in context of SFTP protocol? Do you need PGP authentication to be used in SSH/SFTP? This is a very rare configuration (though it's supported).

Sincerely yours
Eugene Mayevski
Posted: 04/06/2009 11:06:33
by Daniel Kurz (Basic support level)
Joined: 04/06/2009
Posts: 4

That's right. I try to logon a SFTP with PGP authentication and I'm forced to use PGP authentication with an passphrase - in WINSCP it looks like on the the picture I've enclosed the posting - but that all in automation without user inputs.
With which of your components is that possible? At the moment I'm using
In these components I can nowhere put the given passphrase.


Posted: 04/06/2009 11:12:19
by Eugene Mayevski (Team)

From the screenshot I guess that you are not using PGP authentication, but you are using public key authentication using the key encrypted in OpenPGP packet. So the task is
a) get the key from OpenPGP packet
b) use this key for public-key authentication in SSH.

The second part is done using TElSSHKey class and most SSH/SFTP samples include support for public key authentication using TElSSHKey class.
As for the first part, the answer depends on how exactly the key is stored. I am leaving this topic for our OpenPGP developer, who will give you some clue.

Sincerely yours
Eugene Mayevski
Posted: 04/06/2009 16:00:25
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

Hi. Looking at your key name, it seems that you are using SSH public key authentication, which needs password for secret (SSH) key.
So you just need to pass valid key passphrase to TElSSHKey.LoadPrivateKey() method, add this key to TElSSHMemoryKeyStorage, and set the TElSimpleSFTPClient.KeyStorage value to it.
Posted: 04/07/2009 02:13:16
by Daniel Kurz (Basic support level)
Joined: 04/06/2009
Posts: 4

  KeyStorage := TElSSHMemoryKeyStorage.Create(nil);
  SFTP := TElSimpleSftpClient.Create(nil);
  SFTP.OnError := SFTPOnError;
  SFTP.OnKeyValidate := SFTPOnKeyValidate;
  SFTP.OnAuthenticationFailed := SFTPOnAuthenticationFailed;
  SFTP.OnAuthenticationSuccess := SFTPOnAuthenticationSuccess;
  SFTP.OnCloseConnection := SFTPOnCloseConnection;
  SFTP.OnSend := SFTPOnSend;
  SFTP.OnFileOperation := SFTPOnFileOperation;
  SFTP.Port := 22;
  SFTP.AuthenticationTypes := 20; //22 and not SSH_AUTH_TYPE_PUBLICKEY;
  SFTP.KeyStorage := KeyStorage;
   Key := TElSSHKey.Create;
   if (pKeyFile <> '') and (Key.LoadPrivateKey(pKeyFile) = 0) then //loading privat_cs.ppk
     SFTP.AuthenticationTypes := SFTP.AuthenticationTypes or SSH_AUTH_TYPE_PUBLICKEY;
     SFTP.AuthenticationTypes := SFTP.AuthenticationTypes and not SSH_AUTH_TYPE_PUBLICKEY;

Ok, thank you. I've added the key(-file) with your and samples help - but where can I put my passphrase? How can I add the passphrase-string to TElSSHKey?
Posted: 04/07/2009 03:20:31
by Mykola Olshevsky (Basic support level)
Joined: 07/07/2005
Posts: 450

You should provide passphrase to the .LoadPrivateKey method, i.e. Key.LoadPrivateKey(pKeyFile, 'secret_password');
Posted: 04/07/2009 04:16:00
by Daniel Kurz (Basic support level)
Joined: 04/06/2009
Posts: 4

Simply said:

That's it!
It works!

Thank you very much for your support!
Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.



Topic viewed 2591 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!