%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /snap/core22/current/usr/share/subiquity/subiquitycore/__pycache__/
Upload File :
Create Path :
Current File : //snap/core22/current/usr/share/subiquity/subiquitycore/__pycache__/ssh.cpython-310.pyc

o

K��^)�@svddlZddlZddlZddlmZe�d�Zdd�Zdd�Ze	d�Z
d	Ze	d
�Zdd�Z
d
d�Zdd�Zdd�ZdS)�N)�run_commandzsubiquitycore.sshcCs|tddg�}|jdkrt�d|j�gSg}|j��D]}|�d�r-|�|�	dd�d�qg}|D]	}|�
t|��q2|S)zzQuery sshd to find the host keys and then fingerprint them.

    Returns a sequence of (key-type, fingerprint) pairs.
    �sshdz-Trzsshd -T failed %rzhostkey N�)r�
returncode�log�debug�stderr�stdout�
splitlines�
startswith�append�split�extend�fingerprints)�config�keyfiles�line�info�keyfile�r�)/usr/share/subiquity/subiquitycore/ssh.py�host_key_fingerprintss

�rcCs|g}tdd|g�}|jdkrt�d||j�|S|j��D]}|���dd��	�}|d}|d�d	�}|�
||f�q|S)
Nz
ssh-keygenz-lfrzssh-keygen -lf %s failed %r�
�r���z())rrrrrr	r
�strip�replacer
r)rr�cpr�parts�fingerprint�keytyperrrr,s
rzThe host key fingerprints are:
z$
    {keytype:{width}} {fingerprint}z9The {keytype} host key fingerprint is:
    {fingerprint}
cCs
tt��S)N)�summarize_host_keysrrrrr�
host_key_infoGs
r"cCs�t|�dkrdSt|�dkr|\\}}tt�j||d�Stt�g}tdd�|D��}|D]\}}|�tj|||d��q,d�|�S)Nrrr)r rcSsg|]\}}t|��qSr)�len)�.0r �_rrr�
<listcomp>Ssz'summarize_host_keys.<locals>.<listcomp>)r r�width)	r#r%�single_host_key_tmpl�format�host_keys_intro�maxr�
host_key_tmpl�join)rr r�lines�longest_typerrrr!Ks

�


�
r!cCsVzt�|�}Wntyt�d|�gYSwd�|j�}tj�	|�r)t
|�SgS)Nzgetpwnam(%s) failedz{}/.ssh/authorized_keys)�pwd�getpwnam�KeyErrorr�	exceptionr)�pw_dir�os�path�existsr)�username�	user_info�
user_key_filerrr�user_key_fingerprints[s�r;cCs�ddlm}ddlm}|�}|��|��dd}g}t|dd�d�D]"}|d	|vr.q%|d
D]}|ddkrF|�|d
�d�d�q2q%|S)Nr)�Prober)�NETDEV_IGNORED_IFACE_TYPES�network�linkscSs|ddS)N�netlink_data�namer)�linkrrr�<lambda>osz$get_ips_standalone.<locals>.<lambda>)�key�type�	addresses�scope�global�address�/)	�probert.proberr<�subiquitycore.models.networkr=�
probe_network�get_results�sortedrr
)r<r=�proberr?�ipsrB�addrrrr�get_ips_standalonehs��rS)�loggingr5r0�subiquitycore.utilsr�	getLoggerrrrr%r*r,r(r"r!r;rSrrrr�<module>s


Zerion Mini Shell 1.0