Cant get ScSSHClient to work with key - not even following step by step instructions

Cant get ScSSHClient to work with key - not even following step by step instructions

Hi,

I cannot get the ScSSHClient component to connect when using a key instead of a password.

I've been trying out these steps:

Here's what I've done:
  1. create SSH server on Ubuntu, connecting via username/password works
  2. create SSH keys on Ubuntu, resulting in 2 files
  3. on a Delphi form, I dropped 2 components: ScSSHClient and ScMemoryStorage
  4. ScSSHClient has the following properties:
    PrivateKeyName=private
    Hostname=(set to the IP address of the ssh server host on Ubuntu)
    HostKeyName=public (not sure if this is required)
    Authentication=atPublicKey
    KeyStorage=ScMemoryStorage1
  5. the MemoryStorage component does not save the keys to the form file, so on FormCreate I'm creating a TScKey object, import the private key file, set KeyName to 'private'
  6. ScSSHClient.OnSeverKeyValidate event:
    1. const
        HOST_KEY_NAME = 'public';

      procedure TForm33.ScSSHClient1ServerKeyValidate(Sender: TObject;
        NewServerKey: TScKey; var Accept: Boolean);
      var
        Key: TScKey;
        fp, msg: string;
        KeyCreated: boolean;
      begin
        Key := ScMemoryStorage1.Keys.FindKey(HOST_KEY_NAME);
        if (Key = nil) or not Key.Ready or ((Key <> nil) and not NewServerKey.Equals(Key)) then begin
          KeyCreated := False;
          NewServerKey.GetFingerPrint(haMD5, fp);
          msg := 'The authenticity of server can not be verified.'#13#10 +
                 'Fingerprint for the key received from server: ' + fp + '.'#13#10 +
                 'Key length: ' + IntToStr(NewServerKey.BitCount) + ' bits.'#13#10 +
                 'Are you sure you want to continue connecting?';

          if MessageDlg(msg, mtConfirmation, [mbOk, mbCancel], 0) = mrOk then begin
            if Key = nil then begin
              Key := TScKey.Create(nil);
              KeyCreated := True;
            end;
            try
              Key.Assign(NewServerKey);
              Key.KeyName := HOST_KEY_NAME;
              if KeyCreated then
                ScMemoryStorage1.Keys.Add(Key);
            except
              Key.Free;
              raise;
            end;

            Accept := True;
          end;
        end;
      end;
During run-time, when I connect the SSH Client component, the following happens:

- the event above triggers, a key is added to the key storage when OK is clicked
- authentication fails:
---------------------------
Project28
---------------------------
Authentication failed
publickey,password.
---------------------------
OK   
---------------------------

What am I doing wrong?

With regards,

Martijn Tonies