Private Key authentication

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
fulopattila122
Posts: 9
Joined: Wed 28 Nov 2007 15:57

Private Key authentication

Post by fulopattila122 » Thu 29 Nov 2007 10:28

Hello,

I would like to set up a connection with Private Key authentication.
I have a private key that looks very much like this below, and I'm able to connect to the server using putty and this key:

PuTTY-User-Key-File-2: ssh-rsa
Encryption: none
Comment: rsa-key-20071127
Public-Lines: 4
AAAAB3NzaC1gdaEAAAALJQAUAIEAo6okxawnWoJWFd9QHd3yhhKd4KyFL9csQDqP
czBCPDlgHJUrXYa89XZ0pyZZ3RUCDtff7x1w+Z7ZCG0DyFuKxWt2gda3enFEz1aF
WGDiTuLHjPgHZIe441R4f4FZgDGBgqsRakdID+Ca1OZaVY8iaeC1E61mLsNs80uu
CqT2M4E=
Private-Lines: 8
AAAAgGW8ysAREYtKGpY+tiL/lsILkpKUwX6ag0qFRGoywWO09o5O45sAGxPvsEw6
bsZnAUd/RgsXfZRAJgtoFxuuhrET1uTi7pV877dhWfddi3wveTTr9GDLLLqZPwib
hekP4MGY1cMvMUQrjC3U4aX7Wq7+AQa8Hy/S/DaYRheaEhitAAsAQQDQxI7GI77I
vecY9e2cbuc2j/g6zFJYw8b3NIk1s8OrZRwIhGNN4dUHlqjdDUsfHb2wedtWrMyV
s8D8we5IAlaRAaAfQQDIsUsONVC-JqIg9MPJyriyisoVdqL+Sfr4gE4gi4hhb/XO
FDHaqLbsIkZ7GMI0tdqtgaW4GrCR11rv9HweCT7xAAAAQQCwTBA/2ghBbuYIqGVw
w8aR3lqtzRcr11qksFYQs5gFKT2EMrIbR3kDi0agkmpXOaoBs7/KlIPRFcYK4ERf
MfNu
Private-MAC: b1a03ff86c69da2ea9aa7ee3ff196a442b55d5c2

I'm creating an application that needs to connect using such private keys. The private keys are only known at runtime (So I can't import them in advance at design time). My question is, what is the correct method of using and/or importing these keys runtime in order to connect to the SSH Server with these keys?

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

Post by Dimon » Fri 30 Nov 2007 07:52

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;

fulopattila122
Posts: 9
Joined: Wed 28 Nov 2007 15:57

Post by fulopattila122 » Fri 30 Nov 2007 08:35

Hello Dimon,

Thank you very much for the information, now I am sure it will work.

Regards

Post Reply