At the moment I'm working on a Java program to monitor our UNIX scripts. The problem is that we get a new server next week and I have to change my program, so it could connect to the new machine, using JSch. Currently I'm using this way to get a connection to the old servers:
JSch jsch = new JSch();
session = jsch.getSession(user, host);
session.setPassword(password);
session.setConfig("StrictHostKeyChecking", "no");
session.setTimeout(60000);
session.connect();
While testing it on the new server, i got the problem, that it would stop at session.connect() and won't go any further.
After some research i found out, that the JSch lib i was using, was to old for the new OpenSSH Version from the Server, so I upgraded my JSch to version 0.1.54, but even that won't kill the problem.
Actual I'm trying to use SSH-Keys for this, but the problem is still the same, no stacktrace, nothing. Here is the actual code I try to get running:
String private_key = "path_to_file";
jsch.addIdentity(private_key);
session = jsch.getSession(user, host, 22);
session.setTimeout(60000);
session.connect();
Keys:
SSH-2 RSA
Client:
JRE 1.8.0_112<br>
JSch 0.1.54
Server:
OpenSSH 7.2p2<br>
OpenSSL 1.0.2g
With this configuration on the Server it's working:
OpenSSH 6.6.1p1
OpenSSL 1.0.1f
EDIT
Adding
java.util.Properties config = new java.util.Properties();
config.put("StrictHostKeyChecking", "no");
config.put("PreferredAuthentications", "password");
Solved the Problem for me