Server : Apache System : Linux iad1-shared-b8-43 6.6.49-grsec-jammy+ #10 SMP Thu Sep 12 23:23:08 UTC 2024 x86_64 User : dh_edsupp ( 6597262) PHP Version : 8.2.26 Disable Function : NONE Directory : /lib/python3/dist-packages/boto/manage/__pycache__/ |
Upload File : |
o ckF[�9 � @ s� d Z ddlmZ ddlZddlZddlZddlZddlZddlZddl Z ddl mZ G dd� de�Z G dd� de�ZG d d � d e�Zdd� Z ddd�ZdS )a The cmdshell module uses the paramiko package to create SSH connections to the servers that are represented by instance objects. The module has functions for running commands, managing files, and opening interactive shell sessions over those connections. � )�interactive_shellN)�StringIOc @ s� e Zd ZdZ d"dd�Zd#dd �Zd d� Zdd � Zdd� Zd$dd�Z dd� Z dd� Zdd� Zdd� Z dd� Zdd� Zd d!� ZdS )%� SSHClientae This class creates a paramiko.SSHClient() object that represents a session with an SSH server. You can use the SSHClient object to send commands to the remote host and manipulate files on the remote host. :ivar server: A Server object or FakeServer object. :ivar host_key_file: The path to the user's .ssh key files. :ivar uname: The username for the SSH connection. Default = 'root'. :ivar timeout: The optional timeout variable for the TCP connection. :ivar ssh_pwd: An optional password to use for authentication or for unlocking the private key. �~/.ssh/known_hosts�rootNc C sp || _ || _|| _|| _tjj|j|d�| _t� � | _ | j �� | j �t j�|�� | j �t�� � | �� d S )N)�password)�server� host_key_file�uname�_timeout�paramiko�RSAKey�from_private_key_file�ssh_key_file�_pkeyr �_ssh_client�load_system_host_keys�load_host_keys�os�path� expanduser�set_missing_host_key_policy� AutoAddPolicy�connect)�selfr r r �timeout�ssh_pwd� r �6/usr/lib/python3/dist-packages/boto/manage/cmdshell.py�__init__3 s � zSSHClient.__init__� c C s d}||k rzz| j j| jj| j| j| jd� W dS tjyC } z|j \}}|dv r8t d� t�d� |d7 }n� W Y d}~n7d}~w t jy` t d| jj � t d � td � |d7 }Y n tyu t d� t�d� |d7 }Y nw ||k st d� dS ) z� Connect to an SSH server and authenticate with it. :type num_retries: int :param num_retries: The maximum number of connection attempts. r )�username�pkeyr N)�3 �= �o z/SSH Connection refused, will retry in 5 secondsr � z:%s has an entry in ~/.ssh/known_hosts and it doesn't matchzCEdit that file to remove the entry and then hit return to try againzHit Enter when readyz8Unexpected Error from SSH Connection, retry in 5 secondsz"Could not establish SSH connection)r r r �hostnamer r r �socket�error�args�print�time�sleepr �BadHostKeyException� raw_input�EOFError)r �num_retries�retry�xxx_todo_changeme�value�messager r r r B s<