diff --git a/actions/ssh b/actions/ssh
index e73ff1210..08b5a9de4 100755
--- a/actions/ssh
+++ b/actions/ssh
@@ -28,12 +28,16 @@ import stat
import subprocess
import sys
+from plinth import action_utils
+
def parse_arguments():
"""Return parsed command line arguments as dictionary."""
parser = argparse.ArgumentParser()
subparsers = parser.add_subparsers(dest='subcommand', help='Sub command')
+ subparsers.add_parser('setup', help='Setup SSH server')
+
get_keys = subparsers.add_parser('get-keys',
help='Get SSH authorized keys')
get_keys.add_argument('--username')
@@ -47,6 +51,11 @@ def parse_arguments():
return parser.parse_args()
+def subcommand_setup(arguments):
+ """Setup Open SSH server."""
+ action_utils.dpkg_reconfigure('openssh-server', {})
+
+
def get_user_homedir(username):
"""Return the home dir of a user by looking up in password database."""
try:
diff --git a/data/etc/plinth/modules-enabled/ssh b/data/etc/plinth/modules-enabled/ssh
new file mode 100644
index 000000000..7186045a1
--- /dev/null
+++ b/data/etc/plinth/modules-enabled/ssh
@@ -0,0 +1 @@
+plinth.modules.ssh
diff --git a/plinth/modules/ssh/__init__.py b/plinth/modules/ssh/__init__.py
new file mode 100644
index 000000000..2e7fc36f4
--- /dev/null
+++ b/plinth/modules/ssh/__init__.py
@@ -0,0 +1,66 @@
+#
+# This file is part of Plinth.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
+"""
+Plinth module for OpenSSH server.
+"""
+
+from django.utils.translation import ugettext_lazy as _
+
+from plinth import actions
+from plinth import service as service_module
+from plinth.menu import main_menu
+from plinth.views import ServiceView
+
+version = 1
+
+is_essential = True
+
+managed_services = ['ssh']
+
+managed_packages = ['openssh-server']
+
+name = _('Secure Shell (SSH) Server')
+
+description = [
+ _('A Secure Shell server uses the secure shell protocol to accept '
+ 'connections from remote computers. An authorized remote computer '
+ 'can perform administration tasks, copy files or run other services '
+ 'using such connections.')
+]
+
+service = None
+
+
+def init():
+ """Intialize the ssh module."""
+ menu = main_menu.get('system')
+ menu.add_urlname(name, 'glyphicon-console', 'ssh:index')
+
+ global service
+ service = service_module.Service(
+ managed_services[0], name, ports=['ssh'], is_external=True)
+
+
+def setup(helper, old_version=False):
+ """Configure the module."""
+ actions.superuser_run('ssh', ['setup'])
+
+
+class SshServiceView(ServiceView):
+ service_id = managed_services[0]
+ description = description
diff --git a/plinth/modules/ssh/tests/__init__.py b/plinth/modules/ssh/tests/__init__.py
new file mode 100644
index 000000000..e69de29bb
diff --git a/plinth/modules/ssh/urls.py b/plinth/modules/ssh/urls.py
new file mode 100644
index 000000000..bbd995536
--- /dev/null
+++ b/plinth/modules/ssh/urls.py
@@ -0,0 +1,29 @@
+#
+# This file is part of Plinth.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as
+# published by the Free Software Foundation, either version 3 of the
+# License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program. If not, see .
+#
+
+"""
+URLs for the Secure Shell Server module.
+"""
+
+from django.conf.urls import url
+
+from plinth.modules.ssh import SshServiceView
+
+
+urlpatterns = [
+ url(r'^sys/ssh/$', SshServiceView.as_view(), name='index'),
+]
diff --git a/plinth/service.py b/plinth/service.py
index 5f228efb8..2944b58cb 100644
--- a/plinth/service.py
+++ b/plinth/service.py
@@ -113,13 +113,10 @@ class Service(object):
def init():
"""Register some misc. services that don't fit elsewhere."""
-
Service('http', _('Web Server'), ports=['http'], is_external=True,
is_enabled=True)
Service('https', _('Web Server over Secure Socket Layer'), ports=['https'],
is_external=True, is_enabled=True)
- Service('ssh', _('Secure Shell (SSH) Server'), ports=['ssh'],
- is_external=True, is_enabled=True)
Service('plinth', format_lazy(_('{box_name} Web Interface (Plinth)'),
box_name=_(cfg.box_name)),
ports=['https'], is_external=True, is_enabled=True)