You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@karaf.apache.org by jb...@apache.org on 2012/12/11 14:47:17 UTC
svn commit: r1420157 - in /karaf/branches/karaf-2.2.x:
assemblies/apache-karaf/src/main/distribution/text/etc/
shell/ssh/src/main/java/org/apache/karaf/shell/ssh/
shell/ssh/src/main/resources/OSGI-INF/blueprint/
Author: jbonofre
Date: Tue Dec 11 13:47:16 2012
New Revision: 1420157
URL: http://svn.apache.org/viewvc?rev=1420157&view=rev
Log:
[KARAF-2050] Allow to configure the SSHd idle timeout
Modified:
karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/distribution/text/etc/org.apache.karaf.shell.cfg
karaf/branches/karaf-2.2.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
karaf/branches/karaf-2.2.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java
karaf/branches/karaf-2.2.x/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
Modified: karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/distribution/text/etc/org.apache.karaf.shell.cfg
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/distribution/text/etc/org.apache.karaf.shell.cfg?rev=1420157&r1=1420156&r2=1420157&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/distribution/text/etc/org.apache.karaf.shell.cfg (original)
+++ karaf/branches/karaf-2.2.x/assemblies/apache-karaf/src/main/distribution/text/etc/org.apache.karaf.shell.cfg Tue Dec 11 13:47:16 2012
@@ -28,6 +28,12 @@ sshPort=8101
sshHost=0.0.0.0
#
+# The sshdIdleTimeout defines the inactivity timeout to logout the SSH session.
+# The sshdIdleTimeout is in milliseconds, and the default is set to 30 minutes.
+#
+sshIdleTimeout=1800000
+
+#
# sshRealm defines which JAAS domain to use for password authentication.
#
sshRealm=karaf
Modified: karaf/branches/karaf-2.2.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java?rev=1420157&r1=1420156&r2=1420157&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java (original)
+++ karaf/branches/karaf-2.2.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java Tue Dec 11 13:47:16 2012
@@ -35,12 +35,15 @@ public class SshServerAction extends Osg
private final Logger log = LoggerFactory.getLogger(getClass());
- @Option(name="-p", aliases={ "--port" }, description = "The port to setup the SSH server (Default: 8101)", required = false, multiValued = false)
+ @Option(name = "-p", aliases = { "--port" }, description = "The port to setup the SSH server (Default: 8101)", required = false, multiValued = false)
private int port = 8101;
- @Option(name="-b", aliases={ "--background"}, description = "The service will run in the background (Default: true)", required = false, multiValued = false)
+ @Option(name = "-b", aliases = { "--background" }, description = "The service will run in the background (Default: true)", required = false, multiValued = false)
private boolean background = true;
+ @Option(name = "-i", aliases = { "--idle-timeout" }, description = "")
+ private long idleTimeout = 1800000;
+
private BlueprintContainer container;
private String sshServerId;
@@ -59,11 +62,16 @@ public class SshServerAction extends Osg
log.debug("Created server: {}", server);
+ // port number
server.setPort(port);
+ // idle timeout
+ server.getProperties().put(SshServer.IDLE_TIMEOUT, new Long(idleTimeout).toString());
+
+ // starting the SSHd server
server.start();
- System.out.println("SSH server listening on port " + port);
+ System.out.println("SSH server listening on port " + port + " (idle timeout " + idleTimeout + "ms)");
if (!background) {
synchronized (this) {
Modified: karaf/branches/karaf-2.2.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java?rev=1420157&r1=1420156&r2=1420157&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java (original)
+++ karaf/branches/karaf-2.2.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java Tue Dec 11 13:47:16 2012
@@ -26,6 +26,7 @@ public class SshServerFactory {
private static final Logger LOGGER = LoggerFactory.getLogger(SshServerFactory.class);
+ private long idleTimeout;
private boolean start;
private SshServer server;
@@ -42,9 +43,18 @@ public class SshServerFactory {
this.start = start;
}
+ public long getIdleTimeout() {
+ return idleTimeout;
+ }
+
+ public void setIdleTimeout(long idleTimeout) {
+ this.idleTimeout = idleTimeout;
+ }
+
public void start() {
if (start) {
try {
+ server.getProperties().put(SshServer.IDLE_TIMEOUT, new Long(idleTimeout).toString());
server.start();
} catch (Exception e) {
LOGGER.info("Error updating SSH server", e);
Modified: karaf/branches/karaf-2.2.x/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.2.x/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml?rev=1420157&r1=1420156&r2=1420157&view=diff
==============================================================================
--- karaf/branches/karaf-2.2.x/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml (original)
+++ karaf/branches/karaf-2.2.x/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml Tue Dec 11 13:47:16 2012
@@ -39,6 +39,7 @@
<cm:default-properties>
<cm:property name="sshPort" value="8101"/>
<cm:property name="sshHost" value="0.0.0.0"/>
+ <cm:property name="sshIdleTimeout" value="1800000"/>
<cm:property name="sshRealm" value="karaf"/>
<cm:property name="sshRole" value="$[karaf.admin.role]"/>
<cm:property name="hostKey" value="$[karaf.base]/etc/host.key"/>
@@ -123,6 +124,7 @@
destroy-method="stop" activation="eager">
<argument ref="sshServer"/>
<property name="start" value="$[karaf.startRemoteShell]"/>
+ <property name="idleTimeout" value="${sshIdleTimeout}"/>
</bean>
<reference id="commandProcessor" interface="org.apache.felix.service.command.CommandProcessor">