Current File : //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|jp�d|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