|
Server : LiteSpeed System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64 User : nandedex ( 1060) PHP Version : 8.1.33 Disable Function : NONE Directory : /opt/cppython/lib/python3.8/site-packages/paramiko/__pycache__/ |
U
P��g�3 � @ s� d dl mZmZ d dlZd dlZd dlZd dlmZ d dlm Z d dl
mZ d dlm
Z
mZ d dlmZmZmZmZ d dlmZ G d d
� d
e�ZG dd� de�ZG d
d� d�ZdS )� )�encodebytes�decodebytesN)�MutableMapping)�sha1)�HMAC)�PKey�UnknownKeyType)�
get_logger�constant_time_bytes_eq�b�u)�SSHExceptionc @ s� e Zd ZdZd#dd�Zdd� Zdd� Zd d
� Zdd� Zd
d� Z dd� Z
dd� Zdd� Zdd� Z
dd� Zdd� Zdd� Zdd� Zdd � Zed$d!d"��ZdS )%�HostKeysaZ
Representation of an OpenSSH-style "known hosts" file. Host keys can be
read from one or more files, and then individual hosts can be looked up to
verify server keys during SSH negotiation.
A `.HostKeys` object can be treated like a dict; any dict lookup is
equivalent to calling `lookup`.
.. versionadded:: 1.5.3
Nc C s g | _ |dk r| �|� dS )z�
Create a new HostKeys object, optionally loading keys from an OpenSSH
style host-key file.
:param str filename: filename to load host keys from, or ``None``
N)�_entries�load)�self�filename� r �>/opt/cppython/lib/python3.8/site-packages/paramiko/hostkeys.py�__init__/ s zHostKeys.__init__c C sH | j D ](}||jkr|j�� |kr||_ dS q| j �t|g|�� dS )a.
Add a host key entry to the table. Any existing entry for a
``(hostname, keytype)`` pair will be replaced.
:param str hostname: the hostname (or IP) to add
:param str keytype: key type (``"ssh-rsa"`` or ``"ssh-dss"``)
:param .PKey key: the key to add
N)r � hostnames�key�get_name�append�HostKeyEntry)r �hostnameZkeytyper �er r r �add; s
zHostKeys.addc
C s� t |d���}t|d�D ]�\}}|�� }t|�dks|d dkr@qzt�||�}W n tk
rh Y qY nX |dk r|j}|D ]}| �||j �r||j�
|� q|t|j�r| j�|� qW 5 Q R X dS )a]
Read a file of known SSH host keys, in the format used by OpenSSH.
This type of file unfortunately doesn't exist on Windows, but on
posix, it will usually be stored in
``os.path.expanduser("~/.ssh/known_hosts")``.
If this method is called multiple times, the host keys are merged,
not cleared. So multiple calls to `load` will just call `add`,
replacing any existing entries and adding new ones.
:param str filename: name of the file to read host keys from
:raises: ``IOError`` -- if there was an error reading the file
�r� r �#N)
�open� enumerate�strip�lenr � from_liner
r �checkr �remover r )r r �f�lineno�line�entryZ
_hostnames�hr r r r J s
z
HostKeys.loadc C s<