title: JSch - Problems with session.connect()
body: <p>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:</p>
  
  <pre><code>JSch jsch = new JSch();
  session = jsch.getSession(user, host);
  session.setPassword(password);
  session.setConfig("StrictHostKeyChecking", "no");
  session.setTimeout(60000);
  session.connect();
  </code></pre>
  
  <p>While testing it on the new server, i got the problem, that it would stop at <code>session.connect()</code> and won't go any further.<br>
  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:</p>
  
  <pre><code>String private_key = "path_to_file";
  jsch.addIdentity(private_key);
  session = jsch.getSession(user, host, 22);
  session.setTimeout(60000);
  session.connect();
  </code></pre>
  
  <p>Keys:<br>
  <code>SSH-2 RSA</code></p>
  
  <p>Client:<br>
  <code>JRE 1.8.0_112&lt;br&gt;</code>
  <code>JSch 0.1.54</code></p>
  
  <p>Server:<br>
  <code>OpenSSH 7.2p2&lt;br&gt;</code>
  <code>OpenSSL 1.0.2g</code></p>
  
  <p><strong>With this configuration on the Server it's working</strong>:<br>
  OpenSSH 6.6.1p1<br>
  OpenSSL 1.0.1f</p>
  
  <p><strong>EDIT</strong> <br>
  Adding</p>
  
  <pre><code>java.util.Properties config = new java.util.Properties();
  config.put("StrictHostKeyChecking", "no");
  config.put("PreferredAuthentications", "password");
  </code></pre>
  
  <p>Solved the Problem for me</p>