net.schmizz.sshj.transport.TransportException: Unable to reach a settlement

inari6 picture inari6 · Jul 1, 2014 · Viewed 7.2k times · Source

I am trying to do ssh into other machine using SSHJ. PFA code below (excluded try/catch/finally blocks).

Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
final SSHClient sshClient = new SSHClient();
sshClient.addHostKeyVerifier(new PromiscuousVerifier());
sshClient.connect("test-hostname");
sshClient.authPublickey("test-user", private_key_path);
Session session = sshClient.startSession();
Session.Command cmd = session.exec(TEST_SSH_COMMAND);
cmd.join(5, TimeUnit.SECONDS);
if(cmd.getExitStatus() == 0) {
   System.out.println("Success");
}

When I try to execute the above program I am getting following error

[reader] n.s.sshj.transport.TransportImpl - Dying because -net.schmizz.sshj.transport.TransportException: Unable to reach a settlement: [] and [aes128-ctr, aes192-ctr, aes256-ctr, arcfour256, arcfour128, aes128-cbc, 3des-cbc, blowfish-cbc, cast128-cbc, aes192-cbc, aes256-cbc, arcfour, [email protected]]
2014-07-01 20:45:09,021 INFO  [reader] n.s.sshj.transport.TransportImpl - Disconnected - UNKNOWN
2014-07-01 20:45:09,023 ERROR [pool-3-thread-1] net.schmizz.concurrent.Promise - <<kex done>> woke to: net.schmizz.sshj.transport.TransportException: Unable to reach a settlement: [] and [aes128-ctr, aes192-ctr, aes256-ctr, arcfour256, arcfour128, aes128-cbc, 3des-cbc, blowfish-cbc, cast128-cbc, aes192-cbc, aes256-cbc, arcfour, [email protected]]

2014-07-01 20:45:09,024 INFO [pool-3-thread-1] n.s.sshj.transport.TransportImpl - Disconnected - BY_APPLICATION

Can someone help me to debug the issue.

Thanks.

Answer

Roland Schneider picture Roland Schneider · Feb 24, 2015

I had the same problem and it was a class-loading issue here. Another library (winzipaes) had a dependency to another version auf Bouncycastle (bcprov-jdk16) that seemed to have a conflict with the jdk15 version referenced by SSHJ.

Explicitly excluding the jdk16 version helped for me (however I haven't tested the code that uses winzipaes yet).