{"record":{"id":"3023d0408b18abf1","repo":"apache/dolphinscheduler","slug":"failed-to-add-public-key-identity","errorCode":null,"errorMessage":"Failed to add public key identity","messagePattern":"Failed to add public key identity","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-ssh/src/main/java/org/apache/dolphinscheduler/plugin/datasource/ssh/SSHUtils.java","lineNumber":59,"sourceCode":"        session = client.connect(connectionParam.getUser(), connectionParam.getHost(), connectionParam.getPort())\n                .verify(5000).getSession();\n        // add password identity\n        String password = connectionParam.getPassword();\n        if (StringUtils.isNotEmpty(password)) {\n            session.addPasswordIdentity(password);\n        }\n\n        // add private key identity\n        String privateKey = connectionParam.getPrivateKey();\n        if (StringUtils.isNotEmpty(privateKey)) {\n            try {\n                KeyPairResourceLoader loader = SecurityUtils.getKeyPairResourceParser();\n                Collection<KeyPair> keyPairCollection = loader.loadKeyPairs(null, null, null, privateKey);\n                for (KeyPair keyPair : keyPairCollection) {\n                    session.addPublicKeyIdentity(keyPair);\n                }\n            } catch (Exception e) {\n                throw new Exception(\"Failed to add public key identity\", e);\n            }\n        }\n        session.setSessionHeartbeat(SessionHeartbeatController.HeartbeatType.IGNORE, Duration.ofSeconds(3));\n        return session;\n    }\n}\n","sourceCodeStart":41,"sourceCodeEnd":66,"githubUrl":"https://github.com/apache/dolphinscheduler/blob/02eac45a1b6676e639fcbfb4be2243de5771b05d/dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-ssh/src/main/java/org/apache/dolphinscheduler/plugin/datasource/ssh/SSHUtils.java#L41-L66","documentation":"Thrown in SSHUtils.getSession while installing the private-key identity onto the Apache MINA SSHD session: the KeyPairResourceLoader failed to parse the configured private key (bad format, unsupported algorithm, wrong passphrase-protected content), so session.addPublicKeyIdentity never succeeds and the exception wraps the parser error.","triggerScenarios":"Thrown at dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-ssh/src/main/java/org/apache/dolphinscheduler/plugin/datasource/ssh/SSHUtils.java:59 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the private key stored in the datasource is a valid OpenSSH/PEM key and not truncated or password-protected without supplying the passphrase","Regenerate the key pair (ssh-keygen -t rsa/ed25519) and re-paste the new private key","Check the wrapped cause in the stack trace for the exact parser error"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"02eac45a1b6676e639fcbfb4be2243de5771b05d","analyzedAt":"2026-09-06T17:43:00.555Z","contentChangedAt":"2026-09-06T17:43:00.555Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}