summaryrefslogtreecommitdiff
path: root/cloudinit
diff options
context:
space:
mode:
Diffstat (limited to 'cloudinit')
-rw-r--r--cloudinit/config/cc_ssh_authkey_fingerprints.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/cloudinit/config/cc_ssh_authkey_fingerprints.py b/cloudinit/config/cc_ssh_authkey_fingerprints.py
index d4f136c2..35a68709 100644
--- a/cloudinit/config/cc_ssh_authkey_fingerprints.py
+++ b/cloudinit/config/cc_ssh_authkey_fingerprints.py
@@ -17,14 +17,12 @@
# 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
FP_HASH_TYPE = 'md5'
FP_SEGMENT_LEN = 2
@@ -34,7 +32,7 @@ FP_SEGMENT_SEP = ":"
def _split_hash(bin_hash):
split_up = []
for i in xrange(0, len(bin_hash), FP_SEGMENT_LEN):
- split_up.append(bin_hash[i:i+FP_SEGMENT_LEN])
+ split_up.append(bin_hash[i:i + FP_SEGMENT_LEN])
return split_up
@@ -54,7 +52,8 @@ def _gen_fingerprint(b64_text):
def _pprint_key_entries(user, key_fn, key_entries, 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', 'Options', 'Comment']
@@ -69,7 +68,8 @@ def _pprint_key_entries(user, key_fn, key_entries, prefix='ci-info: '):
authtbl_s = tbl.get_string()
max_len = len(max(authtbl_s.splitlines(), 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_s.splitlines())
for line in lines:
@@ -82,5 +82,6 @@ def handle(name, cfg, cloud, log, _args):
"logging of ssh fingerprints disabled"), name)
user = util.get_cfg_option_str(cfg, "user", "ubuntu")
- (auth_key_fn, auth_key_entries) = ssh_util.extract_authorized_keys(user, cloud.paths)
+ extract = ssh_util.extract_authorized_keys
+ (auth_key_fn, auth_key_entries) = extract(user, cloud.paths)
_pprint_key_entries(user, auth_key_fn, auth_key_entries)