cloud-init/cloud-init-0.6.2-sshkeytypes.patch

67 lines
2.8 KiB
Diff
Raw Normal View History

2011-09-23 23:36:24 +00:00
Index: cloud-init/cloudinit/CloudConfig/cc_ssh.py
===================================================================
--- cloud-init.orig/cloudinit/CloudConfig/cc_ssh.py
+++ cloud-init/cloudinit/CloudConfig/cc_ssh.py
2011-09-29 01:15:39 +00:00
@@ -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
2011-09-23 23:36:24 +00:00
@@ -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')
2011-09-29 01:15:39 +00:00
@@ -82,11 +82,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/libexec/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:
2011-09-23 23:36:24 +00:00
Index: cloud-init/cloudinit/util.py
===================================================================
--- cloud-init.orig/cloudinit/util.py
+++ cloud-init/cloudinit/util.py
@@ -84,6 +84,7 @@ def get_cfg_option_str(yobj, key, defaul
2011-09-23 23:36:24 +00:00
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"