{"record":{"id":"2c7eb70d40facb07","repo":"infiniflow/ragflow","slug":"failed-to-connect-to-ssh-host-self-username-sel","errorCode":null,"errorMessage":"Failed to connect to SSH host {self.username}@{self.host}:{self.port}: {exc}","messagePattern":"Failed to connect to SSH host (.+?)@(.+?):(.+?): (.+?)","errorType":"exception","errorClass":"SandboxProviderConfigError","httpStatus":null,"severity":"critical","filePath":"agent/sandbox/providers/ssh.py","lineNumber":274,"sourceCode":"            return False\n\n    def _assert_connectivity(self) -> None:\n        try:\n            client = self._create_ssh_client()\n            try:\n                _, stderr, exit_code = self._run_remote_command(\n                    client,\n                    \"true\",\n                    timeout=min(self.timeout, 10),\n                )\n                if exit_code != 0:\n                    raise SandboxProviderConfigError(f\"SSH connectivity check failed on {self.username}@{self.host}:{self.port}: {stderr or 'remote command returned non-zero exit status'}\")\n            finally:\n                client.close()\n        except SandboxProviderConfigError:\n            raise\n        except Exception as exc:\n            raise SandboxProviderConfigError(f\"Failed to connect to SSH host {self.username}@{self.host}:{self.port}: {exc}\") from exc\n\n    def get_supported_languages(self) -> List[str]:\n        return [\"python\", \"javascript\", \"nodejs\"]\n\n    @staticmethod\n    def get_config_schema() -> Dict[str, Dict]:\n        return {\n            \"host\": {\n                \"type\": \"string\",\n                \"required\": True,\n                \"label\": \"SSH Host\",\n                \"placeholder\": \"192.168.1.10\",\n                \"description\": \"Remote host that will execute generated code.\",\n            },\n            \"port\": {\n                \"type\": \"integer\",\n                \"required\": True,\n                \"label\": \"SSH Port\",","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/infiniflow/ragflow/blob/554fb1133ac3861732235ad9c377eb5e0a770665/agent/sandbox/providers/ssh.py#L256-L292","documentation":"Raised as SandboxProviderConfigError by _assert_connectivity when creating the SSH client or running the probe command throws any non-config exception (the original is chained via 'from exc'). It wraps paramiko/OS-level failures — authentication errors, DNS resolution, refused connections, socket timeouts — into a config error with user@host:port context. The blanket except is deliberate: any transport failure must abort initialization.","triggerScenarios":"initialize()/create_instance() with wrong password or bad private key (paramiko.AuthenticationException); unreachable host (DNS failure, firewall drop -> socket timeout on self.timeout); sshd not listening on the port; host key rejected by RejectPolicy because the host is unknown in known_hosts.","commonSituations":"Typo'd host/port/username in the sandbox config; rotated credentials or expired keys; security group / firewall blocking port 22 (or custom port); first connection to a host with no known_hosts entry while the provider is fail-closed on unknown hosts.","solutions":["Read the chained original exception ('from exc') — it names the real cause (auth, DNS, timeout, host key)","Verify reachability: ssh -p <port> user@host from the same machine","Fix credentials: correct password, or a valid private key/passphrase pair","For unknown-host rejections, ship a known_hosts file and set the known_hosts config option"],"exampleFix":"# before\nprovider.initialize({\"host\": \"10.0.0.5\", \"port\": 22, \"username\": \"u\", \"password\": \"wrong\"})\n# -> SandboxProviderConfigError: Failed to connect ... Authentication failed.\n\n# after\nprovider.initialize({\"host\": \"10.0.0.5\", \"port\": 22, \"username\": \"u\", \"private_key\": key_path, \"known_hosts\": \"/etc/ragflow/known_hosts\"})","handlingStrategy":"retry","validationCode":"import socket\ntry:\n    socket.create_connection((host, port), timeout=5).close()\nexcept OSError:\n    raise RuntimeError(f\"SSH host {host}:{port} unreachable; check network/firewall\")","typeGuard":null,"tryCatchPattern":"from agent.sandbox.providers.base import SandboxProviderConfigError\ntry:\n    provider.initialize(config)\nexcept SandboxProviderConfigError as e:\n    cause = e.__cause__  # real paramiko/OS error\n    if isinstance(cause, (socket.timeout, ConnectionError)):\n        retry_with_backoff(provider.initialize, config, attempts=3)\n    else:\n        raise","preventionTips":["Read e.__cause__ to separate auth vs network vs host-key failures before retrying","Only retry transient classes (timeouts, resets); never retry authentication failures","Pre-seed known_hosts via ssh-keyscan so RejectPolicy cannot surprise you on first connect"],"tags":["ssh","connectivity","authentication","network","configuration"],"backgroundTag":null,"analyzedSha":"554fb1133ac3861732235ad9c377eb5e0a770665","analyzedAt":"2026-08-15T09:20:16.380Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}