diff options
Diffstat (limited to 'cloudinit/config/cc_ssh_authkey_fingerprints.py')
-rw-r--r-- | cloudinit/config/cc_ssh_authkey_fingerprints.py | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/cloudinit/config/cc_ssh_authkey_fingerprints.py b/cloudinit/config/cc_ssh_authkey_fingerprints.py index 6fb7d7fe..087cc15e 100644 --- a/cloudinit/config/cc_ssh_authkey_fingerprints.py +++ b/cloudinit/config/cc_ssh_authkey_fingerprints.py @@ -17,20 +17,23 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. import base64 -import glob import hashlib -import os from prettytable import PrettyTable -from cloudinit import util from cloudinit import ssh_util +from cloudinit import util def _split_hash(bin_hash): split_up = [] +<<<<<<< TREE + for i in xrange(0, len(bin_hash), FP_SEGMENT_LEN): + split_up.append(bin_hash[i:i + FP_SEGMENT_LEN]) +======= for i in xrange(0, len(bin_hash), 2): split_up.append(bin_hash[i:i+2]) +>>>>>>> MERGE-SOURCE return split_up @@ -56,7 +59,8 @@ def _is_printable_key(entry): def _pprint_key_entries(user, key_fn, key_entries, hash_meth='md5', prefix='ci-info: '): if not key_entries: - message = "%sno authorized ssh keys fingerprints found for user %s." % (prefix, user) + message = ("%sno authorized ssh keys fingerprints found for user %s." + % (prefix, user)) util.multi_log(message) return tbl_fields = ['Keytype', 'Fingerprint (%s)' % (hash_meth), 'Options', 'Comment'] @@ -73,7 +77,8 @@ def _pprint_key_entries(user, key_fn, key_entries, hash_meth='md5', prefix='ci-i authtbl_lines = authtbl_s.splitlines() max_len = len(max(authtbl_lines, key=len)) lines = [ - util.center("Authorized keys fingerprints from %s for user %s" % (key_fn, user), "+", max_len), + util.center("Authorized keys fingerprints from %s for user %s" % + (key_fn, user), "+", max_len), ] lines.extend(authtbl_lines) for line in lines: @@ -86,6 +91,6 @@ def handle(name, cfg, cloud, log, _args): "logging of ssh fingerprints disabled"), name) user_name = util.get_cfg_option_str(cfg, "user", "ubuntu") - hash_meth = util.get_cfg_option_str(cfg, "authkey_hash", "md5") - (auth_key_fn, auth_key_entries) = ssh_util.extract_authorized_keys(user_name, cloud.paths) + extract = ssh_util.extract_authorized_keys + (auth_key_fn, auth_key_entries) = extract(user_name, cloud.paths) _pprint_key_entries(user_name, auth_key_fn, auth_key_entries, hash_meth) |