fix: allocate PTY for agent install to work with sudo requiretty

The remote server has 'Defaults requiretty' in sudoers, which prevents
sudo from running without a TTY. Modified SSHService::exec() to accept
an optional  parameter that allocates a pseudo-terminal, and
extracts the exit status from output when PTY is used (since phpseclib
doesn't return exit status in PTY mode).
This commit is contained in:
2026-06-11 18:52:40 -04:00
parent f4c534c020
commit 63bf125420
2 changed files with 16 additions and 4 deletions

View File

@@ -63,7 +63,7 @@ class AgentService
return ['success' => false, 'error' => 'SSH connection failed'];
}
$result = $ssh->exec($remoteCommand, 120);
$result = $ssh->exec($remoteCommand, 120, true);
$ssh->disconnect();
$output = trim($result['output']);
@@ -127,7 +127,7 @@ class AgentService
return ['success' => false, 'error' => 'SSH connection failed'];
}
$result = $ssh->exec($remoteCommand, 60);
$result = $ssh->exec($remoteCommand, 60, true);
$ssh->disconnect();
$output = trim($result['output']);