Details
-
Bug
-
Status: Resolved
-
Minor
-
Resolution: Fixed
-
1.0.0
-
None
Description
I was getting the following exception on various systems when calling auth().verify() on a ClientSession object.
org.apache.sshd.common.SshException: Session is closed -
at org.apache.sshd.client.session.ClientUserAuthService.preClose() in ClientUserAuthService.java:225.
at org.apache.sshd.common.util.CloseableUtils$AbstractCloseable.close() in CloseableUtils.java:346.
at org.apache.sshd.common.util.CloseableUtils$ParallelCloseable.doClose() in CloseableUtils.java:235.
at org.apache.sshd.common.util.CloseableUtils$SimpleCloseable.close() in CloseableUtils.java:202.
at org.apache.sshd.common.util.CloseableUtils$SequentialCloseable$1.operationComplete() in CloseableUtils.java:260.
at org.apache.sshd.common.util.CloseableUtils$SequentialCloseable$1.operationComplete() in CloseableUtils.java:254.
at org.apache.sshd.common.util.CloseableUtils$SequentialCloseable.doClose() in CloseableUtils.java:270.
at org.apache.sshd.common.util.CloseableUtils$SimpleCloseable.close() in CloseableUtils.java:202.
at org.apache.sshd.common.util.CloseableUtils$AbstractInnerCloseable.doCloseImmediately() in CloseableUtils.java:441.
at org.apache.sshd.common.session.AbstractSession.doCloseImmediately() in AbstractSession.java:538.
at org.apache.sshd.common.util.CloseableUtils$AbstractCloseable.close() in CloseableUtils.java:347.
at org.apache.sshd.common.session.AbstractSession.exceptionCaught() in AbstractSession.java:525.
at org.apache.sshd.common.session.AbstractSessionIoHandler.exceptionCaught() in AbstractSessionIoHandler.java:49.
at org.apache.sshd.common.io.nio2.Nio2Session.exceptionCaught() in Nio2Session.java:137.
at org.apache.sshd.common.io.nio2.Nio2Session.access$500() in Nio2Session.java:46.
at org.apache.sshd.common.io.nio2.Nio2Session$2.onFailed() in Nio2Session.java:240.
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler$2.run() in Nio2CompletionHandler.java:45.
at java.security.AccessController.doPrivileged() in AccessController.java:-2.
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.failed() in Nio2CompletionHandler.java:42.
at org.apache.sshd.common.io.nio2.Nio2Session$2.onCompleted() in Nio2Session.java:233.
at org.apache.sshd.common.io.nio2.Nio2Session$2.onCompleted() in Nio2Session.java:212.
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler$1.run() in Nio2CompletionHandler.java:34.
at java.security.AccessController.doPrivileged() in AccessController.java:-2.
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed() in Nio2CompletionHandler.java:31.
at sun.nio.ch.Invoker.invokeUnchecked() in Invoker.java:126.
at sun.nio.ch.Invoker$2.run() in Invoker.java:218.
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run() in AsynchronousChannelGroupImpl.java:112.
at java.util.concurrent.ThreadPoolExecutor.runWorker() in ThreadPoolExecutor.java:1142.
at java.util.concurrent.ThreadPoolExecutor$Worker.run() in ThreadPoolExecutor.java:617.
After enabling all log levels it turned out the actual error is a different one and is only logged as a warning:
java.security.InvalidAlgorithmParameterException: Prime size must be multiple of 64, and can only range from 512 to 2048 (inclusive)
at com.sun.crypto.provider.DHKeyPairGenerator.initialize(DHKeyPairGenerator.java:120)
at java.security.KeyPairGenerator$Delegate.initialize(KeyPairGenerator.java:674)
at java.security.KeyPairGenerator.initialize(KeyPairGenerator.java:411)
at org.apache.sshd.common.kex.DHG.getE(DHG.java:66)
at org.apache.sshd.client.kex.DHGEXClient.next(DHGEXClient.java:110)
at org.apache.sshd.common.session.AbstractSession.doHandleMessage(AbstractSession.java:395)
at org.apache.sshd.common.session.AbstractSession.handleMessage(AbstractSession.java:349)
at org.apache.sshd.client.session.ClientSessionImpl.handleMessage(ClientSessionImpl.java:487)
at org.apache.sshd.common.session.AbstractSession.decode(AbstractSession.java:848)
at org.apache.sshd.common.session.AbstractSession.messageReceived(AbstractSession.java:331)
at org.apache.sshd.common.session.AbstractSessionIoHandler.messageReceived(AbstractSessionIoHandler.java:57)
at org.apache.sshd.common.io.nio2.Nio2Session$2.onCompleted(Nio2Session.java:220)
at org.apache.sshd.common.io.nio2.Nio2Session$2.onCompleted(Nio2Session.java:212)
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler$1.run(Nio2CompletionHandler.java:34)
at java.security.AccessController.doPrivileged(Native Method)
at org.apache.sshd.common.io.nio2.Nio2CompletionHandler.completed(Nio2CompletionHandler.java:31)
at sun.nio.ch.Invoker.invokeUnchecked(Invoker.java:126)
at sun.nio.ch.Invoker$2.run(Invoker.java:218)
at sun.nio.ch.AsynchronousChannelGroupImpl$1.run(AsynchronousChannelGroupImpl.java:112)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
This is definitely not just a warning and should be an error. Also I think it should also be the actual exception you get from auth(). The "Session is closed" error is not helpful at all.