46 lines
2.1 KiB
Diff
46 lines
2.1 KiB
Diff
Index: cloud-init/cloudinit/CloudConfig/cc_ssh.py
|
|
===================================================================
|
|
--- cloud-init.orig/cloudinit/CloudConfig/cc_ssh.py
|
|
+++ cloud-init/cloudinit/CloudConfig/cc_ssh.py
|
|
@@ -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])
|
|
|
|
try:
|
|
user = util.get_cfg_option_str(cfg,'user')
|
|
Index: cloud-init/cloudinit/util.py
|
|
===================================================================
|
|
--- cloud-init.orig/cloudinit/util.py
|
|
+++ cloud-init/cloudinit/util.py
|
|
@@ -77,6 +77,7 @@ def get_cfg_option_str(yobj, key, defaul
|
|
|
|
def get_cfg_option_list_or_str(yobj, key, default=None):
|
|
if not yobj.has_key(key): return default
|
|
+ if yobj[key] is None: return []
|
|
if isinstance(yobj[key],list): return yobj[key]
|
|
return([yobj[key]])
|
|
|
|
Index: cloud-init/tools/write-ssh-key-fingerprints
|
|
===================================================================
|
|
--- cloud-init.orig/tools/write-ssh-key-fingerprints
|
|
+++ cloud-init/tools/write-ssh-key-fingerprints
|
|
@@ -3,8 +3,7 @@
|
|
echo
|
|
echo "#############################################################"
|
|
echo "-----BEGIN SSH HOST KEY FINGERPRINTS-----"
|
|
-ssh-keygen -l -f /etc/ssh/ssh_host_rsa_key.pub
|
|
-ssh-keygen -l -f /etc/ssh/ssh_host_dsa_key.pub
|
|
+echo /etc/ssh/ssh_host_*key.pub | xargs -n 1 ssh-keygen -l -f
|
|
echo "-----END SSH HOST KEY FINGERPRINTS-----"
|
|
echo "#############################################################"
|
|
} | logger -p user.info -s -t "ec2"
|