܍~c UdZddlZddlZddlmZddlmZmZddlm Z ddl m Z ddl m Z mZddlmZmZdd lmZdd lmZd Zd d deegeddggdZe ed<eeZdZd dZdZ d!dZdede de dededdf dZdS)"z;SSH AuthKey Fingerprints: Log fingerprints of user SSH keysN)Logger)ssh_utilutil)Cloud)Config) MetaSchema get_meta_doc) ALL_DISTROSug_util) PER_INSTANCE) SimpleTablezWrite 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``. cc_ssh_authkey_fingerprintszSSH AuthKey Fingerprintsz!Log fingerprints of user SSH keyszno_ssh_fingerprints: truezauthkey_hash: sha512)idnametitle descriptiondistros frequencyexamplesactivate_by_schema_keysmetacg}tdt|dD]"}||||dz#|S)Nr)rangelenappend)bin_hashsplit_upis N/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh_authkey_fingerprints.py _split_hashr!+sOH 1c(mmQ ' '--QU+,,,, Osha256c|sdS tj|}|tj|dt |S#ttf$rYdSwxYw)N:?) hashlibnewupdatebase64 b64decodejoinr! hexdigest TypeError ValueError)b64_text hash_methhashers r _gen_fingerprintr42s rY'' f&x00111xx F$4$4$6$677888 z "ss sA.A55B  B ct|j|j|j|jgr@|jr9|jtjvrdSdS)NTF) anykeytyper+commentoptionslowerstriprVALID_KEY_TYPES)entrys r _is_printable_keyr>As_ EM5< FGG M  ##%%++--1III4 5r" ci-info: cj|s!|d|d}tj|dddSdd|zdd g}t|}|D]V}t|rE|jpd t |j|pd |jpd |jpd g} | | W| } | } tt| t } tjd |d |d| g} | | | D]}tj||ddddS)Nz3no authorized SSH keys fingerprints found for user z. TF)consolestderrKeytypezFingerprint (%s)OptionsComment-)keyzAuthorized keys from z for user + )textrBrA)r multi_logr r>r7r4r+r9r8add_row get_string splitlinesrmaxcenterextend)userkey_fn key_entriesr2prefixmessage tbl_fieldstblr=row authtbl_s authtbl_linesmax_lenlineslines r _pprint_key_entriesr_Ks vvttt   wU;;;;i( J j ! !C U # #  $ y99@S $ $ C KK     I((**M#m---..G 5;VVTT B     E LL   #VTTT*5$       r"rcfgcloudlogargsreturnctj|ddr|d|dStj|dd}t j||j\}}|D]o\}} | ds| dr|d|Ftj |\} } t|| | |pdS) Nno_ssh_fingerprintsFz>Skipping module named %s, logging of SSH fingerprints disabled authkey_hashr#no_create_homesystemzXSkipping printing of ssh fingerprints for user '%s' because no home directory is created) ris_truegetdebugget_cfg_option_strr normalize_users_groupsdistroitemsrextract_authorized_keysr_) rr`rarbrcr2users_groups user_name_cfgrSrTs r handlervvs |CGG1599:: L     '^XFFI5c5<HHUG"[[]] G GD 88$ % % (););  II/     ( @ K KIv{IFFFF G Gr")r#)r#r?) __doc__r+r(loggingr cloudinitrrcloudinit.cloudrcloudinit.configrcloudinit.config.schemarr cloudinit.distrosr r cloudinit.settingsr cloudinit.simpletabler MODULE_DESCRIPTIONr__annotations__r!r4r>r_strlistrvr"r rs BAA $$$$$$$$!!!!!!######<<<<<<<<22222222++++++------ ( & 0%}# "  j    ,t      ;F( ( ( ( VG GG#(G/5G=AG GGGGGGr"