OXIESEC PANEL
- Current Dir:
/
/
usr
/
lib
/
python3
/
dist-packages
/
cloudinit
/
config
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
05/09/2024 07:15:07 AM
rwxr-xr-x
📄
__init__.py
14 bytes
04/20/2023 09:31:09 PM
rw-r--r--
📁
__pycache__
-
05/09/2024 07:15:08 AM
rwxr-xr-x
📄
cc_ansible.py
8.37 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_apk_configure.py
5.75 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_apt_configure.py
32.46 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_apt_pipelining.py
2.82 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_bootcmd.py
2.87 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_byobu.py
3.67 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_ca_certs.py
8.06 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_chef.py
13.79 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_disable_ec2_metadata.py
2.04 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_disk_setup.py
32.34 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_fan.py
3.11 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_final_message.py
3.41 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_growpart.py
19.42 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_grub_dpkg.py
5.49 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_install_hotplug.py
3.81 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_keyboard.py
2.08 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_keys_to_console.py
3.63 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_landscape.py
4.86 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_locale.py
1.88 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_lxd.py
17.96 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_mcollective.py
6.2 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_migrator.py
3.51 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_mounts.py
19.03 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_ntp.py
19.7 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_package_update_upgrade_install.py
4.42 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_phone_home.py
5.5 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_power_state_change.py
7.65 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_puppet.py
13.74 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_refresh_rmc_and_interface.py
5.48 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_reset_rmc.py
4.53 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_resizefs.py
10.56 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_resolv_conf.py
5.01 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_rh_subscription.py
17.05 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_rightscale_userdata.py
4.3 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_rsyslog.py
9.77 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_runcmd.py
2.92 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_salt_minion.py
5.54 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_scripts_per_boot.py
1.68 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_scripts_per_instance.py
1.83 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_scripts_per_once.py
1.78 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_scripts_user.py
1.87 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_scripts_vendor.py
2.31 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_seed_random.py
4.81 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_set_hostname.py
4.89 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_set_passwords.py
11.05 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_snap.py
6.39 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_spacewalk.py
3.52 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_ssh.py
14.03 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_ssh_authkey_fingerprints.py
4.24 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_ssh_import_id.py
5.82 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_timezone.py
1.44 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_ubuntu_advantage.py
16.88 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_ubuntu_autoinstall.py
4.56 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_ubuntu_drivers.py
4.63 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_update_etc_hosts.py
5.11 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_update_hostname.py
3.63 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_users_groups.py
7.6 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_wireguard.py
9.28 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_write_files.py
6.75 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_write_files_deferred.py
1.68 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_yum_add_repo.py
7.47 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
cc_zypper_add_repo.py
6.68 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
modules.py
11.43 KB
04/20/2023 09:31:09 PM
rw-r--r--
📄
schema.py
43.14 KB
04/20/2023 09:31:09 PM
rw-r--r--
📁
schemas
-
05/09/2024 07:15:08 AM
rwxr-xr-x
Editing: cc_ssh_authkey_fingerprints.py
Close
# Copyright (C) 2012 Yahoo! Inc. # # Author: Joshua Harlow <harlowja@yahoo-inc.com> # # This file is part of cloud-init. See LICENSE file for license information. """SSH AuthKey Fingerprints: Log fingerprints of user SSH keys""" import base64 import hashlib from logging import Logger from cloudinit import ssh_util, util from cloudinit.cloud import Cloud from cloudinit.config import Config from cloudinit.config.schema import MetaSchema, get_meta_doc from cloudinit.distros import ALL_DISTROS, ug_util from cloudinit.settings import PER_INSTANCE from cloudinit.simpletable import SimpleTable MODULE_DESCRIPTION = """\ Write fingerprints of authorized keys for each user to log. This is enabled by default, but can be disabled using ``no_ssh_fingerprints``. The hash type for the keys can be specified, but defaults to ``sha256``. """ meta: MetaSchema = { "id": "cc_ssh_authkey_fingerprints", "name": "SSH AuthKey Fingerprints", "title": "Log fingerprints of user SSH keys", "description": MODULE_DESCRIPTION, "distros": [ALL_DISTROS], "frequency": PER_INSTANCE, "examples": [ "no_ssh_fingerprints: true", "authkey_hash: sha512", ], "activate_by_schema_keys": [], } __doc__ = get_meta_doc(meta) def _split_hash(bin_hash): split_up = [] for i in range(0, len(bin_hash), 2): split_up.append(bin_hash[i : i + 2]) return split_up def _gen_fingerprint(b64_text, hash_meth="sha256"): if not b64_text: return "" # TBD(harlowja): Maybe we should feed this into 'ssh -lf'? try: hasher = hashlib.new(hash_meth) hasher.update(base64.b64decode(b64_text)) return ":".join(_split_hash(hasher.hexdigest())) except (TypeError, ValueError): # Raised when b64 not really b64... # or when the hash type is not really # a known/supported hash type... return "?" def _is_printable_key(entry): if any([entry.keytype, entry.base64, entry.comment, entry.options]): if ( entry.keytype and entry.keytype.lower().strip() in ssh_util.VALID_KEY_TYPES ): return True return False def _pprint_key_entries( user, key_fn, key_entries, hash_meth="sha256", prefix="ci-info: " ): if not key_entries: message = ( "%sno authorized SSH keys fingerprints found for user %s.\n" % (prefix, user) ) util.multi_log(message, console=True, stderr=False) return tbl_fields = [ "Keytype", "Fingerprint (%s)" % (hash_meth), "Options", "Comment", ] tbl = SimpleTable(tbl_fields) for entry in key_entries: if _is_printable_key(entry): row = [ entry.keytype or "-", _gen_fingerprint(entry.base64, hash_meth) or "-", entry.options or "-", entry.comment or "-", ] tbl.add_row(row) authtbl_s = tbl.get_string() authtbl_lines = authtbl_s.splitlines() max_len = len(max(authtbl_lines, key=len)) lines = [ util.center( "Authorized keys from %s for user %s" % (key_fn, user), "+", max_len, ), ] lines.extend(authtbl_lines) for line in lines: util.multi_log( text="%s%s\n" % (prefix, line), stderr=False, console=True ) def handle( name: str, cfg: Config, cloud: Cloud, log: Logger, args: list ) -> None: if util.is_true(cfg.get("no_ssh_fingerprints", False)): log.debug( "Skipping module named %s, logging of SSH fingerprints disabled", name, ) return hash_meth = util.get_cfg_option_str(cfg, "authkey_hash", "sha256") (users, _groups) = ug_util.normalize_users_groups(cfg, cloud.distro) for (user_name, _cfg) in users.items(): if _cfg.get("no_create_home") or _cfg.get("system"): log.debug( "Skipping printing of ssh fingerprints for user '%s' because " "no home directory is created", user_name, ) continue (key_fn, key_entries) = ssh_util.extract_authorized_keys(user_name) _pprint_key_entries(user_name, key_fn, key_entries, hash_meth) # vi: ts=4 expandtab