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/10 19:40:44 UTC

svn commit: r1419648 - in /karaf/branches/karaf-2.3.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: Mon Dec 10 18:40:42 2012
New Revision: 1419648

URL: http://svn.apache.org/viewvc?rev=1419648&view=rev
Log:
[KARAF-2050] Allow to configure the SSHd idle timeout

Modified:
    karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/distribution/text/etc/org.apache.karaf.shell.cfg
    karaf/branches/karaf-2.3.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
    karaf/branches/karaf-2.3.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java
    karaf/branches/karaf-2.3.x/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml

Modified: karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/distribution/text/etc/org.apache.karaf.shell.cfg
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/distribution/text/etc/org.apache.karaf.shell.cfg?rev=1419648&r1=1419647&r2=1419648&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/distribution/text/etc/org.apache.karaf.shell.cfg (original)
+++ karaf/branches/karaf-2.3.x/assemblies/apache-karaf/src/main/distribution/text/etc/org.apache.karaf.shell.cfg Mon Dec 10 18:40:42 2012
@@ -28,6 +28,12 @@ sshPort=8101
 sshHost=0.0.0.0
 
 #
+# The sshIdleTimeout defines the inactivity timeout to logout the SSH session.
+# The sshIdleTimeout is in milliseconds, and the default is set to 1 minute.
+#
+sshIdleTimeout=60000
+
+#
 # sshRealm defines which JAAS domain to use for password authentication.
 #
 sshRealm=karaf

Modified: karaf/branches/karaf-2.3.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java?rev=1419648&r1=1419647&r2=1419648&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java (original)
+++ karaf/branches/karaf-2.3.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerAction.java Mon Dec 10 18:40:42 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 = "The session idle timeout (Default: 60000ms)", required = false, multiValued = false)
+    private long idleTimeout = 60000;
+
     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.3.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java?rev=1419648&r1=1419647&r2=1419648&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java (original)
+++ karaf/branches/karaf-2.3.x/shell/ssh/src/main/java/org/apache/karaf/shell/ssh/SshServerFactory.java Mon Dec 10 18:40:42 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.3.x/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml
URL: http://svn.apache.org/viewvc/karaf/branches/karaf-2.3.x/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml?rev=1419648&r1=1419647&r2=1419648&view=diff
==============================================================================
--- karaf/branches/karaf-2.3.x/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml (original)
+++ karaf/branches/karaf-2.3.x/shell/ssh/src/main/resources/OSGI-INF/blueprint/shell-ssh.xml Mon Dec 10 18:40:42 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="60000"/>
             <cm:property name="sshRealm" value="karaf"/>
             <cm:property name="sshRole" value="$[karaf.admin.role]"/>
             <cm:property name="hostKey" value="$[karaf.base]/etc/host.key"/>
@@ -122,6 +123,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">