�
܍~c�P � �2 � d dl Z d dlZd dlmZ d dlmZ ej e� � ZdZ dZ
dZd ee� � z dz Z
G d � d
� � Z G d� d� � Zd
� Zd� Zd� Zd� Zd� Zd� Ze fd�Zdd�Z G d� d� � Zd� Zd� Zd� Zdedefd�Ze fd�Zd� ZdS ) � N)�log)�utilz/etc/ssh/sshd_config)�dsa�rsa�ecdsa�ed25519z(ecdsa-sha2-nistp256-cert-v01@openssh.comzecdsa-sha2-nistp256z(ecdsa-sha2-nistp384-cert-v01@openssh.comzecdsa-sha2-nistp384z(ecdsa-sha2-nistp521-cert-v01@openssh.comzecdsa-sha2-nistp521z+sk-ecdsa-sha2-nistp256-cert-v01@openssh.comz"sk-ecdsa-sha2-nistp256@openssh.comz#sk-ssh-ed25519-cert-v01@openssh.comzsk-ssh-ed25519@openssh.comzssh-dss-cert-v01@openssh.comzssh-dssz ssh-ed25519-cert-v01@openssh.comzssh-ed25519zssh-rsa-cert-v01@openssh.comzssh-rsazssh-xmss-cert-v01@openssh.comzssh-xmss@openssh.com� z�no-port-forwarding,no-agent-forwarding,no-X11-forwarding,command="echo 'Please login as the user \"$USER\" rather than the user \"$DISABLE_USER\".';echo;sleep 10;exit �"c �$ � e Zd Z dd�Zd� Zd� ZdS )�AuthKeyLineNc �L � || _ || _ || _ || _ || _ d S �N)�base64�comment�options�keytype�source)�selfr r r r r s �4/usr/lib/python3/dist-packages/cloudinit/ssh_util.py�__init__zAuthKeyLine.__init__F s+ � � ����������������� c � � | j o| j S r )r r �r s r �validzAuthKeyLine.validO s � ��{�+�t�|�+r c �J � g }| j r|� | j � � | j r|� | j � � | j r|� | j � � | j r|� | j � � |s| j S d� |� � S �N� )r �appendr r r r �join)r �tokss r �__str__zAuthKeyLine.__str__R s� � ����<� &��K�K���%�%�%��<� &��K�K���%�%�%��;� %��K�K���$�$�$��<� &��K�K���%�%�%�� "��;���8�8�D�>�>�!r )NNNN)�__name__�
__module__�__qualname__r r r! � r r r r E sI � � � � � �GK�� � � �,� ,� ,�
"�
"�
"�
"�
"r r c � � e Zd ZdZd� Zdd�ZdS )�AuthKeyLineParsera�
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):
c �x � d}d}|t |� � k rz|s
|| dvrn|| }|dz t |� � k r|dz }nJ||dz }|dk r|dk r|dz }n |dk r| }|dz }|t |� � k r|�d|| dv�n|d|� }||d� � � � }||fS )z�
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.
Fr )r � � �\r
N)�len�lstrip)r �ent�quoted�i�curc�nextcr �remains r �_extract_optionsz"AuthKeyLineParser._extract_optionsv s� � � ��
���#�c�(�(�l�l��l�S��V�;�-F�-F��q�6�D��1�u��C��� � ���E�����A��J�E��t�|�|�������E�������#����A��A� �#�c�(�(�l�l��l�S��V�;�-F�-F� �a��c�(�� �Q�R�R����!�!���� � r Nc �� � |� d� � }|� d� � s|� � � dk rt |� � S d� }|� � � } ||� � \ }}}n^# t $ rQ | � |� � \ } }
|�| } ||
� � \ }}}n!# t $ r t |� � cY cY S w xY wY nw xY wt |||||�� � S )Nz
�#� c �4 � | � d d� � }t |� � dk rt dt |� � z � � �|d t vrt d|d z � � �t |� � dk r|� d� � |S )N� zTo few fields: %sr zInvalid keytype %sr7 )�splitr, � TypeError�VALID_KEY_TYPESr )r. r s r �
parse_ssh_keyz.AuthKeyLineParser.parse.<locals>.parse_ssh_key� s� � ��9�9�T�1�%�%�D��4�y�y�1�}�}�� 3�c�$�i�i� ?�@�@�@��A�w�o�-�-�� 4�t�A�w� >�?�?�?� �4�y�y�A�~�~����B�����Kr )r r r r )�rstrip�
startswith�stripr r; r4 )r �src_liner �liner= r. r r r �keyoptsr3 s r �parsezAuthKeyLineParser.parse� s@ � ����v�&�&���?�?�3��� )�4�:�:�<�<�2�#5�#5��x�(�(�(�
�
�
� �j�j�l�l��
-�)6��s�);�);�&�W�f�g�g��� -� -� -� $� 5� 5�c� :� :��W�f���!��
-�-:�]�6�-B�-B�*��&�'�'���
-�
-�
-�"�8�,�,�,�,�,�,�,�
-���� #*�'�
-���� ������
�
�
�
s6 �*A: �:&C�!B1�0C�1C�
C�C�C�Cr )r" |