getServerPublicHostKey(); $serverKeyParts = preg_split('/\s+/', trim($serverKey)); $serverKeyValue = $serverKeyParts[1] ?? $serverKey; $lines = file($knownHostsPath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) ?: []; foreach ($lines as $line) { $parts = preg_split('/\s+/', trim($line)); if (count($parts) < 3 || $parts[0] !== $host) { continue; } if (hash_equals($parts[2], $serverKeyValue)) { return; } } throw new RuntimeException("SSH host key verification failed for {$host}: no matching known_hosts entry"); } }