Viewing File: /usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_authkey_fingerprints.pyo

ó
oBú]c@s˜dZddlZddlZddlmZddlmZddlmZddlm	Z	d„Z
dd	„Zd
„Zddd„Z
d
„ZdS(s
SSH Authkey Fingerprints
------------------------
**Summary:** log fingerprints of user ssh keys

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 ``md5``.

**Internal name:** `` cc_ssh_authkey_fingerprints``

**Module frequency:** per instance

**Supported distros:** all

**Config keys**::

    no_ssh_fingerprints: <true/false>
    authkey_hash: <hash type>
iÿÿÿÿN(tSimpleTable(tug_util(tssh_util(tutilcCsEg}x8tdt|ƒdƒD]}|j|||d!ƒqW|S(Nii(trangetlentappend(tbin_hashtsplit_upti((sP/usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_authkey_fingerprints.pyt_split_hash&stmd5cCsk|s
dSyBtj|ƒ}|jtj|ƒƒdjt|jƒƒƒSWntt	fk
rfdSXdS(Ntt:t?(
thashlibtnewtupdatetbase64t	b64decodetjoinR
t	hexdigestt	TypeErrort
ValueError(tb64_textt	hash_meththasher((sP/usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_authkey_fingerprints.pyt_gen_fingerprint-scCsSt|j|j|j|jgƒrO|jrO|jjƒjƒdkrOtSntS(Nsssh-dsssssh-rsa(sssh-dsssssh-rsa(	tanytkeytypeRtcommenttoptionstlowertstriptTruetFalse(tentry((sP/usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_authkey_fingerprints.pyt_is_printable_key<s
$	s	ci-info: c	CsO|s'd||f}tj|ƒdSdd|ddg}t|ƒ}xi|D]a}t|ƒrP|jpndt|j|ƒpƒd|jpd|jp›dg}	|j	|	ƒqPqPW|j
ƒ}
|
jƒ}tt
|dtƒƒ}tjd||fd	|ƒg}
|
j|ƒx4|
D],}tjd
d||fdtd
tƒqWdS(Ns9%sno authorized ssh keys fingerprints found for user %s.
tKeytypesFingerprint (%s)tOptionstCommentt-tkeys#Authorized keys from %s for user %st+ttexts%s%s
tstderrtconsole(Rt	multi_logRR%RRRRRtadd_rowt
get_stringt
splitlinesRtmaxtcentertextendR#R"(tusertkey_fntkey_entriesRtprefixtmessaget
tbl_fieldsttblR$trowt	authtbl_st
authtbl_linestmax_lentlinestline((sP/usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_authkey_fingerprints.pyt_pprint_key_entriesDs0


	
	

cCs¨tj|jdtƒƒr/|jd|ƒdStj|ddƒ}tj||jƒ\}}xB|j	ƒD]4\}}	t
j|ƒ\}
}t||
||ƒqlWdS(Ntno_ssh_fingerprintss>Skipping module named %s, logging of ssh fingerprints disabledtauthkey_hashR(
Rtis_truetgetR#tdebugtget_cfg_option_strRtnormalize_users_groupstdistrotitemsRtextract_authorized_keysRC(tnametcfgtcloudtlogt_argsRtuserst_groupst	user_namet_cfgR7R8((sP/usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_authkey_fingerprints.pythandlebs		(t__doc__RRtcloudinit.simpletableRtcloudinit.distrosRt	cloudinitRRR
RR%RCRW(((sP/usr/lib/python2.7/site-packages/cloudinit/config/cc_ssh_authkey_fingerprints.pyt<module>s		
Back to Directory File Manager