Hello, I just upgraded to pro version to develop linux applications. There is a problem with oSSHClient. The application freezes when disconnect or free. I added the sample project.
I'm waiting for your help. thanks.
Info;
Product Version: 9.2.4
OS Version: Linux
Platform: x64
Delphi: 10.3.3
Is registered user: True
Code;
Code: Select all
program Project1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
ScSSHClient, ScBridge, ScSSHChannel,
System.SysUtils;
type
TSSH = class
private
oSSHClient: TScSSHClient;
oMemoryStorage: TScFileStorage;
oSSHShell : TScSshShell;
procedure ScSSHClientServerKeyValidate(Sender: TObject; NewServerKey: TScKey; var Accept: Boolean);
procedure Test;
end;
var
SSH: TSSH;
procedure TSSH.ScSSHClientServerKeyValidate(Sender: TObject; NewServerKey: TScKey; var Accept: Boolean);
begin
Accept := True;
end;
procedure TSSH.Test;
var
I: Integer;
x: String;
begin
for I := 0 to 100 do
begin
WriteLN('Create Start - '+IntToStr(i));
oSSHClient := TScSSHClient.Create(nil);
oMemoryStorage := nil;
oMemoryStorage := TScFileStorage.Create(nil);
oSSHClient.KeyStorage := oMemoryStorage;
oSSHClient.HostName := '127.0.0.1';
oSSHClient.Port := 22;
oSSHClient.User := 'root';
oSSHClient.Password := '123456';
oSSHClient.HostKeyAlgorithms.AsString:='ssh-rsa,ssh-dss';
oSSHClient.OnServerKeyValidate := ScSSHClientServerKeyValidate;
oSSHClient.Connect;
oSSHShell := TScSshShell.Create(nil);
oSSHShell.Client:=oSSHClient;
x:=oSSHShell.ExecuteCommand('date');
WriteLN('Create Finish - '+IntToStr(i)+' - '+x);
//
WriteLN('FreeAndNil Start - '+IntToStr(i));
oSSHClient.Disconnect;
FreeAndNil(oSSHClient);
FreeAndNil(oMemoryStorage);
FreeAndNil(oSSHShell);
WriteLN('FreeAndNil Finish - '+IntToStr(i));
end;
end;
begin
try
SSH:=TSSH.Create;
SSH.Test;
{ TODO -oUser -cConsole Main : Insert code here }
except
on E: Exception do
Writeln(E.ClassName, ': ', E.Message);
end;
end.