ó 'KXc@sÛddlZddlZddlmZddlmZejeƒZdZ dZ de fd„ƒYZ de fd„ƒYZ d„Zd„Zd„Zd„Zdd„Zde fd„ƒYZd„Zd„ZdS(iÿÿÿÿN(tlog(tutils/etc/ssh/sshd_configtrsatdsasssh-rsasssh-dsstecdsasssh-rsa-cert-v00@openssh.comsssh-dss-cert-v00@openssh.comsssh-rsa-cert-v01@openssh.comsssh-dss-cert-v01@openssh.coms(ecdsa-sha2-nistp256-cert-v01@openssh.coms(ecdsa-sha2-nistp384-cert-v01@openssh.coms(ecdsa-sha2-nistp521-cert-v01@openssh.comt AuthKeyLinecBs/eZddddd„Zd„Zd„ZRS(cCs1||_||_||_||_||_dS(N(tbase64tcommenttoptionstkeytypetsource(tselfR R RRR((s?/opt/freeware/lib/python2.7/site-packages/cloudinit/ssh_util.pyt__init__,s     cCs|jo|jS(N(RR (R ((s?/opt/freeware/lib/python2.7/site-packages/cloudinit/ssh_util.pytvalid4scCs”g}|jr"|j|jƒn|jr>|j|jƒn|jrZ|j|jƒn|jrv|j|jƒn|sƒ|jSdj|ƒSdS(Nt (RtappendR RRR tjoin(R ttoks((s?/opt/freeware/lib/python2.7/site-packages/cloudinit/ssh_util.pyt__str__7s    N(t__name__t __module__tNoneR R R(((s?/opt/freeware/lib/python2.7/site-packages/cloudinit/ssh_util.pyR+s tAuthKeyLineParsercBs#eZdZd„Zdd„ZRS(s‚ AUTHORIZED_KEYS FILE FORMAT AuthorizedKeysFile specifies the file containing public keys for public key authentication; if none is specified, the default is ~/.ssh/authorized_keys. Each line of the file contains one key (empty (because of the size of the public key encoding) up to a limit of 8 kilo- bytes, which permits DSA keys up to 8 kilobits and RSA keys up to 16 kilobits. You don't want to type them in; instead, copy the identity.pub, id_dsa.pub, or the id_rsa.pub file and edit it. sshd enforces a minimum RSA key modulus size for protocol 1 and protocol 2 keys of 768 bits. The options (if present) consist of comma-separated option specifica- tions. No spaces are permitted, except within double quotes. The fol- lowing option specifications are supported (note that option keywords are case-insensitive): cCsãt}d}x­|t|ƒkr»|s7||dkr»||}|dt|ƒkre|d}Pn||d}|dkr˜|dkr˜|d}n|dkr®| }n|d}qW|d|!}||jƒ}||fS(s× The options (if present) consist of comma-separated option specifica- tions. No spaces are permitted, except within double quotes. Note that option keywords are case-insensitive. iRs is\t"(Rs (tFalsetlentlstrip(R tenttquotedtitcurctnextcRtremain((s?/opt/freeware/lib/python2.7/site-packages/cloudinit/ssh_util.pyt_extract_options[s"      c Csü|jdƒ}|jdƒs0|jƒdkr:t|ƒSd„}|jƒ}y||ƒ\}}}Wnotk rÙ|j|ƒ\} } |dkr¢| }ny|| ƒ\}}}WqÚtk rÕt|ƒSXnXt|d|d|d|d|ƒS( Ns t#tcSsŠ|jddƒ}t|ƒdkr=tdt|ƒƒ‚n|dtkrdtd|dƒ‚nt|ƒdkr†|jdƒn|S(NisTo few fields: %sisInvalid keytype %sR#(tsplitRRt TypeErrortVALID_KEY_TYPESR(RR((s?/opt/freeware/lib/python2.7/site-packages/cloudinit/ssh_util.pyt parse_ssh_key|sR RRR(trstript startswithtstripRR%R!R( R tsrc_lineRtlineR'RR RRtkeyoptsR ((s?/opt/freeware/lib/python2.7/site-packages/cloudinit/ssh_util.pytparsevs"!       N(RRt__doc__R!RR.(((s?/opt/freeware/lib/python2.7/site-packages/cloudinit/ssh_util.pyRGs cCs¡g}y.tjj|ƒr3tj|ƒjƒ}nWn0ttfk rftjt d|ƒg}nXt ƒ}g}x$|D]}|j |j |ƒƒq}W|S(NsError reading lines from %s( tostpathtisfileRt load_filet splitlinestIOErrortOSErrortlogexctLOGRRR.(tfnametlinestparsertcontentsR,((s?/opt/freeware/lib/python2.7/site-packages/cloudinit/ssh_util.pytparse_authorized_keysœs   c Cst|ƒ}xtdt|ƒƒD]†}||}|jƒsDq"nxW|D]O}|jƒscqKn|j|jkrK|}||krš|j|ƒqšqKqKW|||s,  U