Reputation: 95
I am migrating an SFTP client from JSch to Apache MINA SSHD (version 2.11.0) and need to authenticate using a private key stored as a byte array.
With JSch, I used the following approach to authenticate:
JSch jsch = new JSch();
jsch.addIdentity("sftp-key", privateKeyBytes, null, passphrase.getBytes());
Session jschSession = jsch.getSession(username, host, port);
Properties properties = new Properties();
properties.put("StrictHostKeyChecking", "no");
jschSession.setConfig(properties);
jschSession.connect();
Channel channel = jschSession.openChannel("sftp");
In Apache MINA SSHD, I couldn't find a straightforward way to load the private key directly from a byte array. Most examples seem to work with keys stored as files
What I Need Help With:
Any guidance or code examples would be greatly appreciated!
Upvotes: 0
Views: 54
Reputation: 202534
Use SecurityUtils.loadKeyPairIdentities
to read a KeyPair
from any InputStream
.
Upvotes: 0