cli ssh client
Posted: Sun 31 Mar 2019 18:08
hello guys!
I try to create a ssh client. Goal is connect to ssh server and execute a command.
Unfornately I am failing before creating a connecting.
I am using latest secure bridge version (Feb. 2019).
Regards,
dw
I try to create a ssh client. Goal is connect to ssh server and execute a command.
Unfornately I am failing before creating a connecting.
Code: Select all
program sshcli;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
Classes,
ScTypes,
ScUtils,
ScBridge,
ScSSHClient;
var
searchResult: TSearchRec;
ScSSHClient: TScSSHClient;
ScFileStorage: TScFileStorage;
Key, NewServerKey: TScKey;
begin
try
ScFileStorage := TScFileStorage.Create(nil);
ScSSHClient := TScSSHClient.Create(nil);
ScSSHClient.KeyStorage := ScFileStorage;
ScSSHClient.HostName := '192.168.x.y';
ScSSHClient.User := 'user';
ScSSHClient.Password := 'verysecret';
Key := ScSSHClient.KeyStorage.Keys.FindKey(ScSSHClient.HostName);
//Key := TScKey.Create(nil);
try
Key.Assign(NewServerKey);
Key.KeyName := ScSSHClient.HostName;
ScSSHClient.KeyStorage.Keys.Add(Key);
except
Key.Free;
raise;
end;
ScSSHClient.Connect;
except
on E: Exception do
writeln(E.ClassName, ': ', E.Message);
end;
ScSSHClient.DisConnect;
Readln;
end.
Regards,
dw