shell.ExecuteCommand hangs

Discussion of open issues, suggestions and bugs regarding network security and data protection solution - SecureBridge
Post Reply
alex222
Posts: 1
Joined: Sat 09 Apr 2016 15:24

shell.ExecuteCommand hangs

Post by alex222 » Sat 09 Apr 2016 15:34

We are testing SSH related components (Windows 7, Windows XP, Delphi 7)
If we execute the following function (see below) in cycle, shell.ExecuteCommand hangs around 5th-20th iteration.
SSH server: sshd version OpenSSH_6.9, OpenSSL 1.0.2d
Ciphers used aes128-ctr, Kex algorithm diffie-hellman-group14-sha1

Another question - are these components thread safe?
TScSSHClient;
TScFileStorage;
TScSSHShell;

Code: Select all

function TForm1.SSHexec(host,user,psw,command: string; id: integer): string;
var
  ssh: TScSSHClient;
  storage: TScFileStorage;
  shell: TScSSHShell;
  list: TStrings;
  i: Integer;
begin
  ssh:=TScSSHClient.Create(self);
  storage:=TScFileStorage.Create(self);
  shell:=TScSSHShell.Create(self);
  list:=TStringList.Create;
 Try
  ssh.HostName:=host;
  ssh.User:=user;
  ssh.Password:=psw;
  ssh.Timeout := 3;
  ssh.KeyStorage:=storage;
  ssh.OnServerKeyValidate:=sshServerKeyValidate;
  ssh.Connect;

  shell.Client:=ssh;
  shell.Environment.Text:='PATH=/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/user1/.local/bin:/home/user1/bin';
  shell.Connect;
  list.Text:=command;
  Result:=IntToStr(id)+'. ';
  for i:=0 to list.Count-1 do
  begin
    if Result<>'' then Result:=Result+#13#10;
    Result:=Result+shell.ExecuteCommand(list[i]+#13#10);
  end;
  shell.Disconnect;
  ssh.Disconnect;
 except
   on e:Exception do  Result:='Error: '+e.Message;
 end;
  ssh.Free;
  storage.Free;
  shell.Free;
  list.Free;
end;

procedure TForm1.sshServerKeyValidate(Sender: TObject; NewServerKey: TScKey; var Accept: Boolean);
begin
  Accept:=True;
end;

ViktorV
Devart Team
Posts: 3168
Joined: Wed 30 Jul 2014 07:16

Re: shell.ExecuteCommand hangs

Post by ViktorV » Tue 12 Apr 2016 10:10

Yes, our components are thread-safe. Unfortunately, we couldn't reproduce the issue. Please specify the commands you are running.

Post Reply