With JSch I'm calling addIdentity()
to add a private key and getSession()
to open an SSH tunnel.
When running this code locally on my Windows machine the opening of the tunnel is working.
However when running that same code with the same private key on our CI the following error occurs:
2016-12-07 01:01:32 ERROR SSHConnector:25 - invalid privatekey: [B@4bb4de6a
com.jcraft.jsch.JSchException: invalid privatekey: [B@4bb4de6a
at com.jcraft.jsch.KeyPair.load(KeyPair.java:747)
at com.jcraft.jsch.KeyPair.load(KeyPair.java:561)
at com.jcraft.jsch.IdentityFile.newInstance(IdentityFile.java:40)
at com.jcraft.jsch.JSch.addIdentity(JSch.java:408)
at com.jcraft.jsch.JSch.addIdentity(JSch.java:389)
The private key looks something like this:
PuTTY-User-Key-File-2: ssh-rsa
Encryption: none
Comment: imported-openssh-key
Public-Lines: 6
XXXXXXXXXXXXXXXXXXX
Private-Lines: 14
XXXXXXXXXXXXXXXXXX
Private-MAC: XXXXXXXXXXXXXXXX
What could be the error here?