fix(ssh): accept SSH servers that omit an exit-status packet
testConnection gated success on `exit code === 0`, but phpseclib returns false from getExitStatus() when a server omits the optional exit-status message, which would reject a valid login with an empty error. A successful connect() already proves the credential (it throws on auth failure), so the probe now succeeds on any exception-free connect + exec. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>feat/v1-foundation
parent
bc0691a730
commit
07f0a0cb00
|
|
@ -130,12 +130,17 @@ class FleetService
|
|||
try {
|
||||
$ssh = (new SshClient($this->vault, timeout: 10))->connect($server);
|
||||
try {
|
||||
[, $code] = $ssh->run('true');
|
||||
// A successful login (connect() throws otherwise) already proves the
|
||||
// credential; running a trivial command also exercises the exec channel.
|
||||
// Do NOT gate on the exit code: some SSH servers omit the optional
|
||||
// exit-status packet, so getExitStatus() returns false even on success —
|
||||
// reaching here without an exception is proof enough.
|
||||
$ssh->run('true');
|
||||
} finally {
|
||||
$ssh->disconnect();
|
||||
}
|
||||
|
||||
return ['ok' => $code === 0, 'error' => null];
|
||||
return ['ok' => true, 'error' => null];
|
||||
} catch (Throwable $e) {
|
||||
return ['ok' => false, 'error' => $e->getMessage()];
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue