Page 1 of 1
Using public key file
Posted: Tue 13 Mar 2012 15:08
by redandblack
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)
Posted: Thu 15 Mar 2012 13:13
by Dimon
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;
Posted: Mon 09 Apr 2012 12:29
by RWarnecke
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.
Posted: Tue 10 Apr 2012 09:05
by Dimon
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.