403Webshell
Server IP : 80.87.202.40  /  Your IP : 216.73.216.169
Web Server : Apache
System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64
User : bitrix ( 600)
PHP Version : 8.2.27
Disable Function : NONE
MySQL : OFF |  cURL : ON |  WGET : ON |  Perl : ON |  Python : OFF |  Sudo : ON |  Pkexec : ON
Directory :  /lib/python3.11/site-packages/ansible/modules/__pycache__/

Upload File :
current_dir [ Writeable] document_root [ Writeable]

 

Command :


[ Back ]     

Current File : /lib/python3.11/site-packages/ansible/modules/__pycache__/known_hosts.cpython-311.opt-1.pyc
�

���c�5����ddlmZmZmZeZdZdZddlZddl	Z	ddl
Z
ddlZddlZddl
ZddlZddlZddlmZddlmZmZd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zedkre��dSdS)�)�absolute_import�division�print_functiona�	
---
module: known_hosts
short_description: Add or remove a host from the C(known_hosts) file
description:
   - The C(known_hosts) module lets you add or remove a host keys from the C(known_hosts) file.
   - Starting at Ansible 2.2, multiple entries per host are allowed, but only one for each key type supported by ssh.
     This is useful if you're going to want to use the M(ansible.builtin.git) module over ssh, for example.
   - If you have a very large number of host keys to manage, you will find the M(ansible.builtin.template) module more useful.
version_added: "1.9"
options:
  name:
    aliases: [ 'host' ]
    description:
      - The host to add or remove (must match a host specified in key). It will be converted to lowercase so that ssh-keygen can find it.
      - Must match with <hostname> or <ip> present in key attribute.
      - For custom SSH port, C(name) needs to specify port as well. See example section.
    type: str
    required: true
  key:
    description:
      - The SSH public host key, as a string.
      - Required if C(state=present), optional when C(state=absent), in which case all keys for the host are removed.
      - The key must be in the right format for SSH (see sshd(8), section "SSH_KNOWN_HOSTS FILE FORMAT").
      - Specifically, the key should not match the format that is found in an SSH pubkey file, but should rather have the hostname prepended to a
        line that includes the pubkey, the same way that it would appear in the known_hosts file. The value prepended to the line must also match
        the value of the name parameter.
      - Should be of format C(<hostname[,IP]> ssh-rsa <pubkey>).
      - For custom SSH port, C(key) needs to specify port as well. See example section.
    type: str
  path:
    description:
      - The known_hosts file to edit.
      - The known_hosts file will be created if needed. The rest of the path must exist prior to running the module.
    default: "~/.ssh/known_hosts"
    type: path
  hash_host:
    description:
      - Hash the hostname in the known_hosts file.
    type: bool
    default: "no"
    version_added: "2.3"
  state:
    description:
      - I(present) to add the host key.
      - I(absent) to remove it.
    choices: [ "absent", "present" ]
    default: "present"
    type: str
attributes:
  check_mode:
    support: full
  diff_mode:
    support: full
  platform:
    platforms: posix
extends_documentation_fragment:
  - action_common_attributes
author:
- Matthew Vernon (@mcv21)
a�
- name: Tell the host about our servers it might want to ssh to
  ansible.builtin.known_hosts:
    path: /etc/ssh/ssh_known_hosts
    name: foo.com.invalid
    key: "{{ lookup('ansible.builtin.file', 'pubkeys/foo.com.invalid') }}"

- name: Another way to call known_hosts
  ansible.builtin.known_hosts:
    name: host1.example.com   # or 10.9.8.77
    key: host1.example.com,10.9.8.77 ssh-rsa ASDeararAIUHI324324  # some key gibberish
    path: /etc/ssh/ssh_known_hosts
    state: present

- name: Add host with custom SSH port
  ansible.builtin.known_hosts:
    name: '[host1.example.com]:2222'
    key: '[host1.example.com]:2222 ssh-rsa ASDeararAIUHI324324' # some key gibberish
    path: /etc/ssh/ssh_known_hosts
    state: present
N)�
AnsibleModule)�to_bytes�	to_nativec	�0�|d���}|�dd��}|�d��}|�d��}|�d��}|�dd��}|s|d	kr|�d
���|r|rt	||��}|r|�d��s|dz
}t
||||��t|||||��\}}	}
t||
|	||��|d
<|d	kr|
s	|rd|d<|S|j	r'|�
|	p	|dk|k|d
���|r)|s'|d	kr!|�|d|d|gd���d|d<|	s||dkk�r�	t|d��}nX#t$rK}|jtjkrd}n)|�d|�dt!|�������Yd}~nd}~wwxYw	t#jdt&j�|��d���5}
|�Pt-|��D],\}}|
|dzkr	|	s|d	kr�|
�|���-|���|dkr|
�|��ddd��n#1swxYwY|�|
j|��nG#tt6f$r3}|�d|�dt9|�������Yd}~nd}~wwxYwd|d<|S)z
    Add or remove key.
    �name�keyN�path�	hash_host�statez
ssh-keygenT�absentz#No key specified when adding a host��msg�
�diffF�changed�present)rrz-R�-f��check_rc�rzFailed to read �: �w+)�mode�dir�delete�zFailed to write to file )�lower�get�get_bin_path�	fail_json�
hash_host_key�endswith�sanity_check�search_for_host_key�compute_diff�
check_mode�	exit_json�run_command�open�IOError�errno�ENOENT�str�tempfile�NamedTemporaryFile�osr�dirname�	enumerate�write�close�atomic_mover
�OSErrorr)�module�params�hostrrr
r�	sshkeygen�found�replace_or_add�
found_line�inf�e�outf�line_number�lines                �@/usr/lib/python3.11/site-packages/ansible/modules/known_hosts.py�
enforce_staterGus��
�&�>���!�!�D�
�*�*�U�D�
!�
!�C��:�:�f���D��
�
�;�'�'�I��J�J�w���E��#�#�L�$�7�7�I��D�5�H�$�$����B��C�C�C�
�'�y�'��D�#�&�&����3�<�<��%�%���t������s�I�.�.�.�(;�F�D�#�t�U^�(_�(_�%�E�>�:�!�$�
�N�E�3�O�O�F�6�N�
��������!��y���
���.�����!P�E�Y�4F�5�3P�$�V�n�	�	.�	.�	.�
�!�S�!�U�h�.�.����I�t�T�4��>���N�N�N� ��y���!��5�I�#5�6�6�	O��t�S�/�/�C�C���	O�	O�	O��w�%�,�&�&����� � � ����c�!�f�f�f�%M� �N�N�N����������		O����

	0��,�$�B�G�O�O�D�<Q�<Q�Z_�`�`�`�
$�dh��?�-6�s�^�^�)�)�)��T�%�+��/�:�:��:�RW�[c�Rc�Rc�$��
�
�4�(�(�(�(��I�I�K�K�K��I�%�%��J�J�s�O�O�O�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$�
$����
$�
$�
$�
$�
���t�y�$�/�/�/�/����!�	Z�	Z�	Z�����T�T�T�9�UV�<�<�<�!X��Y�Y�Y�Y�Y�Y�Y�Y�����	Z����
!��y���MsV�F�
G1�&AG,�,G1�54K
�)A.J#�K
�#J'�'K
�*J'�+K
�
L�)L	�	Lc
�$�|sdStjd|��r|�d���tjd���5}	|�|��|���nE#t$r8}|�d|j�dt|�������Yd}~nd}~wwxYw|d	|d
|jg}|�
|��\}}}	ddd��n#1swxYwY|dkr|�d���dSdS)
a!Check supplied key is sensible

    host and key are parameters provided by the user; If the host
    provided is inconsistent with the key supplied, then this function
    quits, providing an error to the user.
    sshkeygen is the path to ssh-keygen, found earlier with get_bin_path
    Nz\S+(\s+)?,(\s+)?zlComma separated list of names is not supported. Please pass a single name to lookup in the known_hosts file.rr)rz"Failed to write to temporary file r�-Fr�z?Host parameter does not match hashed host field in supplied key)�re�searchr#r1r2r6�flushr-r
rr+)
r:r<rr=rCrB�sshkeygen_command�rc�stdout�stderrs
          rFr&r&�s�������
�y�$�d�+�+�]����\��	]�	]�	]�
�	$�$�	/�	/�	/�	C�4�	8��J�J�s�O�O�O��J�J�L�L�L�L���	8�	8�	8�����"�i�i�i��1����"7��
8�
8�
8�
8�
8�
8�
8�
8�����	8����'��d�D�$�)�D��#�/�/�0A�B�B���F�F�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C�	C����	C�	C�	C�	C���|�|����^��_�_�_�_�_��|s<�C'�)A1�0C'�1
B3�;.B.�)C'�.B3�3(C'�'C+�.C+c�8�tj�|��durdS|d|d|g}|�|d���\}}}|dkr|dkr|dks|dkrdS|dkr|�d	|||fz�
��|sdS|�d��}	t
|��}
t|	��D]�\}}|dkr�|dd
kr`	ttj
d|���d����}
�O#t$r|�d|z�
��Y�twxYwt
|��}|
ddd�dkr|ddd�dkr|d|
d<|
|krdd|
fcS|
d|dkrdd|
fcS��dS)a2search_for_host_key(module,host,key,path,sshkeygen) -> (found,replace_or_add,found_line)

    Looks up host and keytype in the known_hosts file path; if it's there, looks to see
    if one of those entries matches key. Returns:
    found (Boolean): is host found in path?
    replace_or_add (Boolean): is the key in path different to that supplied by user?
    found_line (int or None): the line where a key of the same type was found
    if found=False, then replace is always False.
    sshkeygen is the path to ssh-keygen, found earlier with get_bin_path
    F)FFNrIrrrJrrz2ssh-keygen failed (rc=%d, stdout='%s',stderr='%s')r)TFNr�#zfound: line (\d+)z:failed to parse output of ssh-keygen for line number: '%s'r<N��|1|T�type)TTN)
r3r�existsr+r#�split�normalize_known_hosts_keyr5�intrKrL�group�
IndexError)r:r<rrr=rNrOrPrQ�lines�new_key�lnum�lr@�	found_keys               rFr'r'�s#��
�w�~�~�d���u�$�$�!�!�"�D�$��d�;�� �+�+�,=��+�N�N��B���
��|�|��"���"��'�'�R�1�W�W�!�!�	�Q�w�w����Q�UW�Y_�ag�Th�h��i�i�i��!� � ��L�L����E�'��,�,�G��U�#�#�.�.���a���7�7��
�q�T�S�[�[�
g�!���+?��!C�!C�!I�!I�!�!L�!L�M�M�
�
���
g�
g�
g�� � �%a�de�%e� �f�f�f�f�f�
g����2�!�4�4�I��v��r��r�"�e�+�+�	�&�0A�"�1�"�0E��0N�0N�"+�F�"3�����)�#�#��U�J�.�.�.�.����I�f�$5�5�5��T�:�-�-�-�-�6��s�5D�#D.�-D.c���tjd��}tj|t	|��t
j�����}|����	��}|dddkrdnd}dttj|�����dttj|������||<d�
|��S)N�r�@rrU�|� )r3�urandom�hmac�newr�hashlib�sha1�digest�striprXr�base64�	b64encode�join)r<r�hmac_key�hashed_host�parts�is      rFr$r$ s����z�"�~�~�H��(�8�X�d�^�^�W�\�B�B�I�I�K�K�K��I�I�K�K�����E�
�1�X�a�[�C�
�
���Q�A�A�&�v�'7��'A�'A�B�B�B�B�I�f�N^�_j�Nk�Nk�Dl�Dl�Dl�m�E�!�H��8�8�E�?�?��c�2�|���}|���}t��}|dddkr-|d|d<|d|d<|d|d<|d|d	<n!|d|d<|d|d<|d|d	<|S)
a~
    Transform a key, either taken from a known_host file or provided by the
    user, into a normalized form.
    The host part (which might include multiple hostnames or be hashed) gets
    replaced by the provided host. Also, any spurious information gets removed
    from the end (like the username@host tag usually present in hostkeys, but
    absent in known_hosts files)
    rrd�optionsrr<�rVrTr)rmrX�dict)r�k�ds   rFrYrY*s����)�)�+�+�C��	�	���A����A���t�A�w�#�~�~���t��)���a�D��&�	��a�D��&�	��Q�4��%����a�D��&�	��a�D��&�	��Q�4��%���Hruc���||ddd�}	t|d��}|���|d<|���n1#t$r$}|jtjkrd|d<Yd}~nd}~wwxYw|d�d��}|s|dkr%|�#d|cxkrt|��kr	nn||dz
=|d	kr|s|�|�|��d�	|��|d
<|S)NrJ)�
before_header�after_header�before�afterrrz	/dev/nullr}rrrr�)
r,�readr7r-r.r/�
splitlines�len�appendrp)	rr@r?rrrrArBr]s	         rFr(r(Cs4������	��D���4��o�o��
������X���	�	�������0�0�0��7�e�l�"�"�$/�D��!����������0����
��N�%�%�a�(�(�E��"�%�8�+�+��1G�A�Q[�Li�Li�Li�Li�_b�ch�_i�_i�Li�Li�Li�Li�Li��*�q�.�!��	���~���1C�
���S�����G�G�E�N�N�D��M��Ks�A�
A3�A.�.A3c
�2�tttdddg���tddd���tdd�	��tdd
d���tdd
dg������d���}t||j��}|jdi|��dS)NTr0r<)�requiredrV�aliasesF)r�rV�no_logz~/.ssh/known_hostsr)�defaultrV�bool)r�rVr�rr)r��choices)r
rrr
r)�
argument_spec�supports_check_mode�)rryrGr;r*)r:�resultss  rF�mainr�[s���
���t�%�&��B�B�B��e�%��>�>�>��2��@�@�@��E���F�F�F��y�8�Y�2G�H�H�H�
�
�
�!�	�	�	�F��F�F�M�2�2�G��F����w�����ru�__main__)�
__future__rrrrV�
__metaclass__�
DOCUMENTATION�EXAMPLESrnr.rjrhr3�os.pathrKr1�ansible.module_utils.basicr�ansible.module_utils._textrrrGr&r'r$rYr(r��__name__r�rurF�<module>r�sE��
A�@�@�@�@�@�@�@�@�@��
�<�
�|��B�
�
�
�������������	�	�	�	�����	�	�	�	�����4�4�4�4�4�4�:�:�:�:�:�:�:�:�M�M�M�`"`�"`�"`�J3�3�3�l���
�
�
�2���0 � � �"�z����D�F�F�F�F�F��ru

Youez - 2016 - github.com/yon3zu
LinuXploit