diff --git a/src/main/scala/servlet/SshServiceListener.scala b/src/main/scala/servlet/SshServiceListener.scala
new file mode 100644
index 0000000..c441e6d
--- /dev/null
+++ b/src/main/scala/servlet/SshServiceListener.scala
@@ -0,0 +1,66 @@
+package servlet
+
+import javax.servlet.{ServletContextEvent, ServletContextListener}
+import org.apache.sshd.SshServer
+import org.apache.sshd.server.keyprovider.SimpleGeneratorHostKeyProvider
+import org.apache.sshd.server._
+import org.apache.sshd.server.session.ServerSession
+import java.io.{OutputStream, InputStream}
+import org.slf4j.LoggerFactory
+
+/*
+ * Start a SSH Service Daemon
+ */
+class SshServiceListener extends ServletContextListener {
+ private val logger = LoggerFactory.getLogger(classOf[SshServiceListener])
+
+ val sshService = SshServer.setUpDefaultServer
+ // TODO make configurable ssh feature
+ val enableSsh = true
+
+ override def contextInitialized(sce: ServletContextEvent): Unit = {
+ if (!enableSsh) return
+ sshService.setPort(29418)
+
+ val authenticator = new MyPasswordAuthenticator
+ sshService.setPasswordAuthenticator(authenticator)
+ // TODO gitbucket.ser should be in GITBUCKET_HOME
+ sshService.setKeyPairProvider(new SimpleGeneratorHostKeyProvider("gitbucket.ser"))
+ sshService.setCommandFactory(new CommandFactory{
+ override def createCommand(command: String): Command = {
+ logger.error("createCommand!")
+ return new Command{
+ override def destroy(): Unit = {}
+
+ override def start(env: Environment): Unit = {
+ logger.info("start command")
+ logger.info(env.getEnv.toString)
+ }
+
+ override def setExitCallback(callback: ExitCallback): Unit = {}
+
+ override def setErrorStream(err: OutputStream): Unit = {}
+
+ override def setOutputStream(out: OutputStream): Unit = {}
+
+ override def setInputStream(in: InputStream): Unit = {}
+ }
+ }
+ })
+ sshService.start()
+ }
+
+ override def contextDestroyed(sce: ServletContextEvent): Unit = {
+ sshService.stop(true)
+ }
+
+}
+
+class MyPasswordAuthenticator extends PasswordAuthenticator {
+ private val logger = LoggerFactory.getLogger(classOf[MyPasswordAuthenticator])
+
+ override def authenticate(username: String, password: String, session: ServerSession): Boolean = {
+ logger.error("authenticate!!!")
+ true
+ }
+}
diff --git a/src/main/webapp/WEB-INF/web.xml b/src/main/webapp/WEB-INF/web.xml
index d57d64e..25bc10e 100644
--- a/src/main/webapp/WEB-INF/web.xml
+++ b/src/main/webapp/WEB-INF/web.xml
@@ -18,6 +18,7 @@
servlet.AutoUpdateListener
+
@@ -26,6 +27,13 @@
+
+
+
+ servlet.SshServiceListener
+
+
+