def __init__( self, host, user=None, port=None, password=None, keyfile=None, load_system_host_keys=True, missing_host_policy=None, encoding="utf8", ): self.host = host kwargs = {} if user: self._fqhost = "%s@%s" % (user, host) kwargs["username"] = user else: self._fqhost = host self._client = paramiko.SSHClient() if load_system_host_keys: self._client.load_system_host_keys() if port is not None: kwargs["port"] = port if keyfile is not None: kwargs["key_filename"] = keyfile if password is not None: kwargs["password"] = password if missing_host_policy is not None: self._client.set_missing_host_key_policy(missing_host_policy) self._client.connect(host, **kwargs) self._sftp = None BaseRemoteMachine.__init__(self, encoding)
def monkey(self, host, encoding='utf8'): self.host = host self._client = paramiko.SSHClient() try: self._client.load_system_host_keys() except: pass self._client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) self._client.connect(host, username='******', password=None) BaseRemoteMachine.__init__(self, encoding)
def __init__(self, host, user=None, port=None, password=None, keyfile=None, load_system_host_keys=True, missing_host_policy=None, encoding="utf8", look_for_keys=None, timeout=None): self.host = host kwargs = {} if user: self._fqhost = "%s@%s" % (user, host) kwargs['username'] = user else: self._fqhost = host self._client = paramiko.SSHClient() if load_system_host_keys: self._client.load_system_host_keys() if port is not None: kwargs["port"] = port if keyfile is not None: kwargs["key_filename"] = keyfile if password is not None: kwargs["password"] = password if missing_host_policy is not None: self._client.set_missing_host_key_policy(missing_host_policy) if look_for_keys is not None: kwargs["look_for_keys"] = look_for_keys if timeout is not None: kwargs["timeout"] = timeout self._client.connect(host, **kwargs) self._sftp = None BaseRemoteMachine.__init__(self, encoding)
def close(self): BaseRemoteMachine.close(self) self._client.close()