Skip to content

Commit 0be6f7c

Browse files
committed
Added configuration for Server Alive Interval
Added configuration for Server Alive Interval. Fixes bastillion-io#110
1 parent 14e1c86 commit 0be6f7c

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/main/java/com/keybox/manage/util/SSHUtil.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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"))) {

src/main/resources/KeyBoxConfig.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ enableInternalAudit=false
2020
deleteAuditLogAfter=90
2121
#set an audit log server using log4j (ex: logstash). Edit the log4j.xml to configure appender.
2222
auditLogAppender=
23+
#The number of seconds that the client will wait before sending a null packet to the server to keep the connection alive
24+
serverAliveInterval=60
2325
#default timeout in minutes for websocket connection (no timeout for <=0)
2426
websocketTimeout=0
2527
#enable SSH agent forwarding

0 commit comments

Comments
 (0)