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:
@@ -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']);
|
||||
|
||||
Reference in New Issue
Block a user