apache/dolphinscheduler · error · Exception
Failed to add public key identity
Error message
Failed to add public key identity
What it means
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.
Source
Thrown at dolphinscheduler-datasource-plugin/dolphinscheduler-datasource-ssh/src/main/java/org/apache/dolphinscheduler/plugin/datasource/ssh/SSHUtils.java:59
session = client.connect(connectionParam.getUser(), connectionParam.getHost(), connectionParam.getPort())
.verify(5000).getSession();
// add password identity
String password = connectionParam.getPassword();
if (StringUtils.isNotEmpty(password)) {
session.addPasswordIdentity(password);
}
// add private key identity
String privateKey = connectionParam.getPrivateKey();
if (StringUtils.isNotEmpty(privateKey)) {
try {
KeyPairResourceLoader loader = SecurityUtils.getKeyPairResourceParser();
Collection<KeyPair> keyPairCollection = loader.loadKeyPairs(null, null, null, privateKey);
for (KeyPair keyPair : keyPairCollection) {
session.addPublicKeyIdentity(keyPair);
}
} catch (Exception e) {
throw new Exception("Failed to add public key identity", e);
}
}
session.setSessionHeartbeat(SessionHeartbeatController.HeartbeatType.IGNORE, Duration.ofSeconds(3));
return session;
}
}
View on GitHub (pinned to 02eac45a1b)
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
Defensive patterns
Strategy: try-catch
When it happens
Trigger: 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.
Common situations: See trigger scenarios.
AI-assisted analysis of apache/dolphinscheduler@02eac45a1b (2026-09-06).
Data as JSON: /api/errors/3023d0408b18abf1.
Report an issue: GitHub.