Error trying to connect to a jumpstation using private key


I’m trying to create a template which can execute a script in a jumpstation. The problem comes when during the execution the server tries to connect via SSH using a private key. In the failing task I’ve put the path to the private key in the server.

After the execution this is the output:

#### Output:

#### Error stream:
com.xebialabs.overthere.RuntimeIOException: Cannot connect to ssh:scp://MYUSER@MYSERVERIP:22
        at com.xebialabs.overthere.ssh.SshConnection.connect(
        at com.xebialabs.overthere.ssh.SshConnectionBuilder.connect(
        at com.xebialabs.overthere.OverthereConnector.buildConnection(
        at com.xebialabs.overthere.OverthereConnector.getConnection(
        at com.xebialabs.overthere.Overthere.getConnection(
        at com.xebialabs.xlrelease.plugin.overthere.RemoteScript.execute(
        at sun.reflect.GeneratedMethodAccessor1025.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(
        at java.lang.reflect.Method.invoke(
        at org.python.core.PyReflectedFunction.__call__(
        at org.python.core.PyReflectedFunction.__call__(
        at org.python.core.PyObject.__call__(
        at org.python.core.PyObject.__call__(
        at org.python.core.PyMethod.__call__(
        at org.python.pycode._pyx576502.f$0(<script>:24)
        at org.python.pycode._pyx576502.call_function(<script>)
        at org.python.core.Py.runCode(
        at org.python.core.__builtin__.eval(
        at org.python.core.__builtin__.eval(
        at org.python.util.PythonInterpreter.eval(
        at org.python.jsr223.PyScriptEngine.eval(
        at org.python.jsr223.PyScriptEngine.eval(
        at com.xebialabs.xlrelease.script.Jsr223ScriptExecutor.lambda$doPrivileged$0(
        at Method)
        at com.xebialabs.xlrelease.script.Jsr223ScriptExecutor.doPrivileged(
        at com.xebialabs.xlrelease.script.jython.JythonScriptExecutor.evalScriptPrivileged(
        at com.xebialabs.xlrelease.script.jython.JythonScriptExecutor.evalScriptWithUtilities(
        at com.xebialabs.xlrelease.script.jython.JythonScriptExecutor.evalScriptWithApi(
        at com.xebialabs.xlrelease.script.DefaultScriptService.executeScript(
        at com.xebialabs.xlrelease.script.DefaultScriptService.lambda$executeCustomScriptTask$1(
        at java.util.concurrent.Executors$
        at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(
        at java.util.concurrent.ScheduledThreadPoolExecutor$
        at java.util.concurrent.ThreadPoolExecutor.runWorker(
        at java.util.concurrent.ThreadPoolExecutor$
Caused by: net.schmizz.sshj.userauth.UserAuthException: Exhausted available authentication methods
        at net.schmizz.sshj.SSHClient.auth(
        at net.schmizz.sshj.SSHClient.authPublickey(
        at net.schmizz.sshj.SSHClient.authPublickey(
        at com.xebialabs.overthere.ssh.SshConnection.connect(
        ... 39 more
Caused by: net.schmizz.sshj.userauth.UserAuthException: Problem getting public key from PKCS8KeyFile{resource=[PrivateKeyFileResource] /path/to/private/key}
        at net.schmizz.sshj.userauth.method.KeyedAuthMethod.putPubKey(
        at net.schmizz.sshj.userauth.method.AuthPublickey.buildReq(
        at net.schmizz.sshj.userauth.method.AuthPublickey.buildReq(
        at net.schmizz.sshj.userauth.method.AbstractAuthMethod.request(
        at net.schmizz.sshj.userauth.UserAuthImpl.authenticate(
        at net.schmizz.sshj.SSHClient.auth(
        ... 42 more
Caused by: Could not read key pair from: [PrivateKeyFileResource] /path/to/private/key
        at net.schmizz.sshj.userauth.keyprovider.PKCS8KeyFile.readKeyPair(
        at net.schmizz.sshj.userauth.keyprovider.BaseFileKeyProvider.getPublic(
        at net.schmizz.sshj.userauth.method.KeyedAuthMethod.putPubKey(
        ... 47 more

It seems to be a format issue with the private key, but it seems to have the correct format. After searching a lot I have no idea about what it can be.

Can you turn on DEBUG logging on package net.schmizz.sshj.userauth.keyprovider?

I’ve added that package in logback.xml:

<logger name="net.schmizz.sshj.userauth.keyprovider" level="debug" />

restarted the server and tried again, and I’m getting the same output. I don’t know if I’m doing something wrong.

Do you have the logs from when the problem occurs? The logs may provide clues to why it’s failing.

Did you check that the key is in PKCS#8 format?

I’ve added the package as said and no log were generated in log folder of the XL Release server more than the output of the execution.
I’ve checked the key and it is in PKCS#8 format, even if I try to connect via SSH from a shell it works.

It seems that support for PKCS#8 private key files was added to a later version of SSHJ than the one we use in the product.

Release uses SSHJ 0.27.0; support for PKCS#8 private key files was added in SSHJ 0.32.0 (See

Please log an issue for this through the support system.

In the meanwhile, would it be possible to use a different private key format?

Kind regards,

Hes Siemelink

1 Like

I guess it will be better to use a different key format for now as you said.

Thank you!