@@ -60,6 +60,7 @@ public class SSHUtil {
6060 public static final String PUB_KEY = PVT_KEY + ".pub" ;
6161
6262
63+ public static final int SERVER_ALIVE_INTERVAL = StringUtils .isNumeric (AppConfig .getProperty ("serverAliveInterval" )) ? Integer .parseInt (AppConfig .getProperty ("serverAliveInterval" )) * 1000 : 60 * 1000 ;
6364 public static final int SESSION_TIMEOUT = 60000 ;
6465 public static final int CHANNEL_TIMEOUT = 60000 ;
6566
@@ -231,9 +232,8 @@ public static HostSystem authAndAddPubKey(HostSystem hostSystem, String passphra
231232 if (password != null && !password .equals ("" )) {
232233 session .setPassword (password );
233234 }
234- java .util .Properties config = new java .util .Properties ();
235- config .put ("StrictHostKeyChecking" , "no" );
236- session .setConfig (config );
235+ session .setConfig ("StrictHostKeyChecking" , "no" );
236+ session .setServerAliveInterval (SERVER_ALIVE_INTERVAL );
237237 session .connect (SESSION_TIMEOUT );
238238
239239
@@ -464,6 +464,7 @@ public static HostSystem openSSHTermOnSystem(String passphrase, String password,
464464 session .setPassword (password );
465465 }
466466 session .setConfig ("StrictHostKeyChecking" , "no" );
467+ session .setServerAliveInterval (SERVER_ALIVE_INTERVAL );
467468 session .connect (SESSION_TIMEOUT );
468469 Channel channel = session .openChannel ("shell" );
469470 if ("true" .equals (AppConfig .getProperty ("agentForwarding" ))) {
0 commit comments