EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How can I login with Passphrase automatically

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.
#9567
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
#9568
Posted: 04/06/2009 10:56:01
by Eugene Mayevski (EldoS Corp.)

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
#9569
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
TElSimpleSftpClient
TElSSHMemoryKeyStorage
TElSBLicenseManager
In these components I can nowhere put the given passphrase.

Thanks!


#9570
Posted: 04/06/2009 11:12:19
by Eugene Mayevski (EldoS Corp.)

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
#9575
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.
#9581
Posted: 04/07/2009 02:13:16
by Daniel Kurz (Basic support level)
Joined: 04/06/2009
Posts: 4

Code
  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
   begin
     KeyStorage.Add(Key);
     SFTP.AuthenticationTypes := SFTP.AuthenticationTypes or SSH_AUTH_TYPE_PUBLICKEY;
   end
   else
   begin
     SFTP.AuthenticationTypes := SFTP.AuthenticationTypes and not SSH_AUTH_TYPE_PUBLICKEY;
   end;
   Key.Free;
   SFTP.Open;


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?
#9583
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');
#9586
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.

Reply

Statistics

Topic viewed 2481 times

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




|

Back to top

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

Got it!