HOME


Mini Shell 1.0
DIR: /snap/core20/current/usr/share/subiquity/subiquitycore/__pycache__/
Upload File :
Current File : //snap/core20/current/usr/share/subiquity/subiquitycore/__pycache__/ssh.cpython-38.pyc
U

K��^��@sNddlZddlmZe�d�Zdd�Zed�ZdZed�Z	d	d
�Z
dd�ZdS)
�N)�run_commandzsubiquitycore.sshcCs�tddg�}|jdkr(t�d|j�gSg}|j��D]$}|�d�r6|�|�	dd�d�q6g}|D]`}tdd	|g�}|jdkr�t�d
||j�qd|j�
��	�}|\}}}	}
|
�
d�}
|�|
|f�qd|S)zzQuery sshd to find the host keys and then fingerprint them.

    Returns a sequence of (key-type, fingerprint) pairs.
    Zsshdz-Trzsshd -T failed %rzhostkey N�z
ssh-keygenz-lfzssh-keygen -lf %s failed %rz())r�
returncode�log�debug�stderr�stdout�
splitlines�
startswith�append�split�strip)ZconfigZkeyfiles�line�infoZkeyfileZcp�partsZlength�fingerprintZhost�keytype�r�)/usr/share/subiquity/subiquitycore/ssh.py�host_key_fingerprintss&



rzThe host key fingerprints are:
z$
    {keytype:{width}} {fingerprint}z:The {keytype} host key fingerprints is:
    {fingerprint}
cCs�t�}t|�dkrdSt|�dkr>|\\}}tt�j||d�Stt�g}tdd�|D��}|D]\}}|�tj|||d��q^d�	|�S)Nr�r)rrcSsg|]\}}t|��qSr)�len)�.0r�_rrr�
<listcomp>Gsz!host_key_info.<locals>.<listcomp>)rr�width)
rrr�single_host_key_tmpl�format�host_keys_intro�maxr�
host_key_tmpl�join)Zfingerprintsrr�linesZlongest_typerrr�
host_key_info>s 

�

�
r#cCs�ddlm}ddlm}|�}|��|��dd}g}t|dd�d�D]D}|d	|kr\qJ|d
D](}|ddkrd|�|d
�d�d�qdqJ|S)Nr)�Prober)�NETDEV_IGNORED_IFACE_TYPESZnetwork�linkscSs|ddS)NZnetlink_data�namer)�linkrrr�<lambda>V�z$get_ips_standalone.<locals>.<lambda>)�key�typeZ	addressesZscope�globalZaddress�/)	Zprobert.proberr$Zsubiquitycore.models.networkr%Z
probe_networkZget_results�sortedrr)r$r%Zproberr&Zipsr(Zaddrrrr�get_ips_standaloneOsr0)ZloggingZsubiquitycore.utilsrZ	getLoggerrrrrr rr#r0rrrr�<module>s