{"record":{"id":"9d5042d27638c265","repo":"apache/seatunnel","slug":"failed-to-connect-to-host-host-by-user-9d5042","errorCode":null,"errorMessage":"Failed to connect to host: \" + host + \" by user: \" + user + \" on port 22","messagePattern":"Failed to connect to host: \" \\+ host \\+ \" by user: \" \\+ user \\+ \" on port 22","errorType":"exception","errorClass":"ClickhouseConnectorException","httpStatus":null,"severity":"critical","filePath":"seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ScpFileTransfer.java","lineNumber":87,"sourceCode":"            clientSession = sshClient.connect(user, host, SCP_PORT).verify().getSession();\n            if (password != null) {\n                clientSession.addPasswordIdentity(password);\n            }\n            if (keyPath != null) {\n                FileKeyPairProvider fileKeyPairProvider =\n                        new FileKeyPairProvider(Paths.get(keyPath));\n                KeyPair fileKeyPair =\n                        fileKeyPairProvider.loadKey(clientSession, KeyPairProvider.SSH_RSA);\n                clientSession.addPublicKeyIdentity(fileKeyPair);\n            }\n            if (!clientSession.auth().verify().isSuccess()) {\n                throw new ClickhouseConnectorException(\n                        ClickhouseConnectorErrorCode.SSH_OPERATION_FAILED,\n                        \"ssh host \" + host + \"authentication failed\");\n            }\n            scpClient = ScpClientCreator.instance().createScpClient(clientSession);\n        } catch (IOException | GeneralSecurityException e) {\n            throw new ClickhouseConnectorException(\n                    ClickhouseConnectorErrorCode.SSH_OPERATION_FAILED,\n                    \"Failed to connect to host: \" + host + \" by user: \" + user + \" on port 22\",\n                    e);\n        }\n    }\n\n    @Override\n    public void transferAndChown(String sourcePath, String targetPath) {\n        try {\n            scpClient.upload(\n                    sourcePath,\n                    targetPath,\n                    ScpClient.Option.Recursive,\n                    ScpClient.Option.TargetIsDirectory,\n                    ScpClient.Option.PreserveAttributes);\n        } catch (IOException e) {\n            throw CommonError.fileOperationFailed(\n                    \"ClickhouseFile\", \"transfer\", sourcePath + \" -> \" + targetPath, e);","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-clickhouse/src/main/java/org/apache/seatunnel/connectors/seatunnel/clickhouse/sink/file/ScpFileTransfer.java#L69-L105","documentation":"ScpFileTransfer.init() catches IOException or GeneralSecurityException during connection/auth setup and rethrows it as SSH_OPERATION_FAILED with a 'Failed to connect to host ... on port 22' message. This is the generic SSH connect failure — the TCP/SSH handshake or crypto setup failed before authentication could be evaluated.","triggerScenarios":"new connect to host:22 throws (connection refused/timeout/unreachable/DNS failure) or key loading throws GeneralSecurityException (unreadable/corrupt key file at keyPath).","commonSituations":"Firewall or security group blocking port 22, wrong host/port in config, remote sshd not running, DNS misresolution, or the SSH key file missing/unreadable by the SeaTunnel worker process.","solutions":["Test connectivity from the SeaTunnel worker: nc -vz <host> 22 or ssh user@host","Verify the host address and that sshd is running on the remote machine","Open port 22 in firewalls/security groups between worker and host","Confirm the key file at keyPath exists and is readable by the process user (check permissions and path)","Note the message hardcodes 'port 22'; if a custom port is used in config, ignore that part and check the actual configured port"],"exampleFix":"// before: unreachable host\nhost = \"10.0.0.99\"\n// after: correct, reachable host (and open port 22)\nhost = \"10.0.0.10\"","handlingStrategy":"validation","validationCode":"# pre-flight connectivity check from the SeaTunnel worker host\nnc -vz -w 5 \"$HOST\" 22 && echo ssh-port-open\n[ -r \"$KEY_PATH\" ] && echo key-readable","typeGuard":null,"tryCatchPattern":"try {\n    transfer.init();\n} catch (ClickhouseConnectorException e) {\n    if (String.valueOf(e.getMessage()).startsWith(\"Failed to connect to host\")) {\n        // inspect e.getCause(): UnknownHost vs ConnectException vs timeout vs security\n        log.error(\"SSH connect failed to {} : {}\", host, e.getCause());\n    }\n    throw e;\n}","preventionTips":["Pre-flight nc/ssh connectivity checks in deployment scripts","Open port 22 (or configured port) in firewalls/security groups","Verify DNS resolution of the host from worker nodes","Confirm key file path and read permissions"],"tags":["ssh","network","connection","scp","clickhouse"],"backgroundTag":"connection-refused","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}