Using public key file

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
redandblack
Posts: 1
Joined: Tue 13 Mar 2012 14:48

Using public key file

Post by redandblack » Tue 13 Mar 2012 15:08

Hello!
I didn't get from samples how to use key files to establish ssh connection.
Could you give me any proper sample of using key-files?

For example I have dsa-file generated via PuttyGen(*.ppk file). The file is protected with passphrase.

Thank you for any advise)

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Thu 15 Mar 2012 13:13

The fact is that PuTTY saves keys in its own format. You should export your keys in the OpenSSH or SSH2 format. For that you should load your private key in PuTTY Key Generator, and export it to any available format using the Conversions menu. After that you should import your key in TScStorage, and set the imported key name in the TScSSHClient.HostKeyName property.
After that connect to the SSH server.

You can use the following code:

Code: Select all

procedure Connect;
var
  Key: TScKey;
begin
  Key := TScKey.Create(ScFileStorage.Keys);
  Key.KeyName := 'key1';
  Key.ImportFrom(Filename);

  ScSSHClient.KeyStorage := ScFileStorage;
  ScSSHClient.HostKeyName := 'key1';
  ScSSHClient.Connect;
end;

RWarnecke
Posts: 24
Joined: Thu 02 Feb 2012 09:08
Location: Stuttgart

Post by RWarnecke » Mon 09 Apr 2012 12:29

I had convert my ppk file with puttygen.exe into openssh key and ssh.com key. If I import the openssh key I get this error:
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EScError with message 'Key is broken'.
---------------------------
Break Continue Help
---------------------------
At the ssh.com key I get the following error :
---------------------------
Debugger Exception Notification
---------------------------
Project Project1.exe raised exception class EScError with message 'Unexpected end of data packet'.
---------------------------
Break Continue Help
---------------------------
Please can you help me.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 10 Apr 2012 09:05

The error can arise, because the key is saved in an encrypted form with the password.
To import this key, you should specify the correct password when calling the ImportFrom method.

Post Reply