I am trying to configure gitlab to run tests upon commiting, howerver in my test i use SFTP ( JSch ) like this:
sftp = new JSch();
sftp.addIdentity(Paths.get(ClassLoader.getSystemResource("private.ppk").toURI()).toString());
//sftp.setKnownHosts("~/.ssh/known_hosts");
Session session = sftp.getSession("test", "localhost", port);
session.setConfig("StrictHostKeyChecking", "no");
session.setConfig("PreferredAuthentications", "publickey");
session.connect();
sftpChannel = (ChannelSftp) session.openChannel("sftp");
sftpChannel.connect();
( port
is random port that is free. )
this code, upon runnin in gitlab enviroment throws
com.jcraft.jsch.JSchException: invalid privatekey: [B@27e47833
Which i quite do not understand why, running this code locally works as it should. The private key which i load from resources also in my gitlab repo.
Why is this happening? Are there any extra steps i omited or why is Jsch on gitlab refusing private key that is valid when i run it locally?
Thanks for help!