summaryrefslogtreecommitdiff
path: root/cloudinit/CloudConfig/cc_ssh.py
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit/CloudConfig/cc_ssh.py')
-rw-r--r--cloudinit/CloudConfig/cc_ssh.py15
1 files changed, 5 insertions, 10 deletions
diff --git a/cloudinit/CloudConfig/cc_ssh.py b/cloudinit/CloudConfig/cc_ssh.py
index 727fd398..296b18f2 100644
--- a/cloudinit/CloudConfig/cc_ssh.py
+++ b/cloudinit/CloudConfig/cc_ssh.py
@@ -31,7 +31,7 @@ def handle(name,cfg,cloud,log,args):
global_log = log
# remove the static keys from the pristine image
- for f in glob.glob("/etc/ssh/ssh_host_*_key*"):
+ for f in glob.glob("/etc/ssh/ssh_host_*key*"):
try: os.unlink(f)
except: pass
@@ -61,10 +61,10 @@ def handle(name,cfg,cloud,log,args):
log.debug("generated %s from %s" % pair)
else:
# if not, generate them
- genkeys ='ssh-keygen -f /etc/ssh/ssh_host_rsa_key -t rsa -N ""; '
- genkeys+='ssh-keygen -f /etc/ssh/ssh_host_dsa_key -t dsa -N ""; '
- genkeys+='ssh-keygen -f /etc/ssh/ssh_host_ecdsa_key -t ecdsa -N ""; '
- subprocess.call(('sh', '-c', "{ %s } </dev/null" % (genkeys)))
+ for keytype in util.get_cfg_option_list_or_str(cfg, 'ssh_genkeytypes',
+ ['rsa', 'dsa', 'ecdsa']):
+ subprocess.call(['ssh-keygen', '-t', keytype, '-N', '',
+ '-f', '/etc/ssh/ssh_host_%s_key' % keytype])
util.restorecon_if_possible('/etc/ssh', recursive=True)
@@ -84,11 +84,6 @@ def handle(name,cfg,cloud,log,args):
util.logexc(log)
log.warn("applying credentials failed!\n")
- send_ssh_keys_to_console()
-
-def send_ssh_keys_to_console():
- subprocess.call(('/usr/lib/cloud-init/write-ssh-key-fingerprints',))
-
def apply_credentials(keys, user, disable_root, disable_root_opts=DISABLE_ROOT_OPTS, log=global_log):
keys = set(keys)
if user: