Hello, I am having a lot of trouble trying to figure out how to authenticate with an SFTP service using only a PEM / Private key.
There doesn't seem to be any examples demonstrating how to make this happen in mina. Looking at the Javadocs and documentation it isn't clear if it is supported. Here is an example of the operation done in SSHTools for a reference of what I am asking for: private static void authenticate(Ssh2Client ssh2, String host, Integer port, String username, InputStream privateKey) { Ssh2PublicKeyAuthentication auth = createKeyAuthentication(privateKey); try { int result = ssh2.authenticate(auth); if (result != SshAuthentication.COMPLETE) { throw new AuthenticationIncomplete(host, port, username, result); } } catch (SshException ex) { throw new UnableToAuthenticate(host, port, username, ex); } } private static Ssh2PublicKeyAuthentication createKeyAuthentication(InputStream privateKey) { try { SshPrivateKeyFile privateKeyFile = SshPrivateKeyFileFactory.parse(StreamUtil.readIntoByteArray(privateKey)); SshKeyPair keyPair = privateKeyFile.toKeyPair(""); Ssh2PublicKeyAuthentication auth = new Ssh2PublicKeyAuthentication(); auth.setPrivateKey(keyPair.getPrivateKey()); auth.setPublicKey(keyPair.getPublicKey()); return auth; } catch (IOException | InvalidPassphraseException ex) { throw new ConfigurationIssue(ex); } } Charles H. Lowery