Ben Howard has proposed merging lp:~utlemming/cloud-init/1494816 into 
lp:cloud-init.

Requested reviews:
  cloud init development team (cloud-init-dev)
Related bugs:
  Bug #1494816 in cloud-init (Ubuntu): "Snappy should enable SSH when 
credentials are provided"
  https://bugs.launchpad.net/ubuntu/+source/cloud-init/+bug/1494816

For more details, see:
https://code.launchpad.net/~utlemming/cloud-init/1494816/+merge/270865

Conditional enablement for SSH on Snappy.
-- 
Your team cloud init development team is requested to review the proposed merge 
of lp:~utlemming/cloud-init/1494816 into lp:cloud-init.
=== modified file 'cloudinit/config/cc_snappy.py'
--- cloudinit/config/cc_snappy.py	2015-05-01 09:38:56 +0000
+++ cloudinit/config/cc_snappy.py	2015-09-11 19:44:42 +0000
@@ -274,7 +274,20 @@
             LOG.warn("'%s' failed for '%s': %s",
                      pkg_op['op'], pkg_op['name'], e)
 
-    disable_enable_ssh(mycfg.get('ssh_enabled', False))
+    # Default to disabling SSH
+    ssh_enabled = mycfg.get('ssh_enabled', False)
+
+    # If the user has not explicitly enabled or disabled SSH, then enable it
+    # when password SSH authentication is requested or there are SSH keys
+    if mycfg.get('ssh_enabled', None) is not False:
+        if len(mycfg.get('public-keys', [])) > 0:
+            LOG.debug("Enabling SSH, user SSH keys provided")
+            ssh_enabled = True
+        elif mycfg.get('ssh_pwauth', False):
+            LOG.debug("Enabling SSH, password authentication requested")
+            ssh_enabled = True
+
+    disable_enable_ssh(ssh_enabled)
 
     if fails:
         raise Exception("failed to install/configure snaps")

_______________________________________________
Mailing list: https://launchpad.net/~cloud-init-dev
Post to     : cloud-init-dev@lists.launchpad.net
Unsubscribe : https://launchpad.net/~cloud-init-dev
More help   : https://help.launchpad.net/ListHelp

Reply via email to