܍~cC UdZddlZddlmZddlmZddlmZmZddl m Z ddl m Z ddl mZmZdd lmZdd lmZgd Zd Zd ZdddeeeedggdZeed<eeZdede de dededdf dZdZdededefdZdS)zSSH Import ID: Import SSH idN)Logger)dedent)subputil)Cloud)Config) MetaSchema get_meta_doc)ug_util) PER_INSTANCE)ubuntudebiancosz ssh-import-ida2This module imports SSH keys from either a public keyserver, usually launchpad or github using ``ssh-import-id``. Keys are referenced by the username they are associated with on the keyserver. The keyserver can be specified by prepending either ``lp:`` for launchpad or ``gh:`` for github to the username. cc_ssh_import_idz SSH Import IDz Import SSH idzi ssh_import_id: - user - gh:user - lp:user )idnametitle descriptiondistros frequencyexamplesactivate_by_schema_keysmetarcfgcloudlogargsreturnct|ds|ddStjts|ddSt |dkr:|d}g}t |dkr |dd}t|||dStj ||j \}}g} | D]\}} g} | drtj |dg} n0 | d} n&#t$r|d|YSwxYw tj| } d| D} n&#t$r|d |YwxYwt | s t| ||#t$r6} tj|d || | | Yd} ~ d} ~ wwxYwt | r| ddS) N ssh_import_idzISkipping module named ssh-import-id, no 'ssh_import_id' directives found.zXssh-import-id is not installed, but module ssh_import_id is configured. Skipping module.rdefaultz+User %s is not configured for ssh_import_idc,g|]}t|S)str).0is C/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh_import_id.py zhandle..bs555Q#a&&555z5User %s is not correctly configured for ssh_import_idzssh-import-id failed for: %s %s)is_key_in_nested_dictdebugrwhichSSH_IMPORT_ID_BINARYwarninglenimport_ssh_idsr normalize_users_groupsdistroitemsrget_cfg_option_list Exception uniq_mergelogexcappend) rrrrruseridsusers_groupselistuser_cfg import_idsexcs r(handlerB7s !o 6 6   !     Z, - -  +     4yyA~~Aw t99q==qrr(CsD#&&&5c5<HHUG E!KKMMx I  1#KKJJ %o6     GNNN  44J55*555JJ    IIG    H   :    :tS 1 1 1 1    K6j    LL            5zzAhs<D  D,+D,0 E E43E4F G$,GGcj|r|s|d||dS tj|n#t$r}|d}~wwxYwddd|tg|z}|d| t j|ddS#t j$r}tj|d||d}~wwxYw) Nz(empty user(%s) or ids(%s). not importingsudoz--preserve-env=https_proxyz-HuzImporting SSH ids for user %s.F)capturez*Failed to run command to import %s SSH ids) r,pwdgetpwnamKeyErrorr.rProcessExecutionErrorrr8)r;r:rrAcmds r(r1r1xs S >$#ttt 5r*) __doc__rFloggingrtextwrapr cloudinitrrcloudinit.cloudrcloudinit.configrcloudinit.config.schemar r cloudinit.distrosr cloudinit.settingsr rr.MODULE_DESCRIPTIONr__annotations__r%rQrBr1rPboolr+r$r*r(r`s#""  !!!!!!######<<<<<<<<%%%%%%++++++ & % %&   %     "#j( ,t  > >>#(>/5>=A> >>>>B111h$CDr*