Python paramiko.BadHostKeyException() Examples

The following are 22 code examples of paramiko.BadHostKeyException(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module paramiko , or try the search function .
Example #1
Source File: RemoteCrashFetcher.py    From LuckyCAT with GNU General Public License v3.0 11 votes vote down vote up
def fetch_remote_crashes(self):
        """
        some exception handling code is taken from https://www.programcreek.com/python/example/105570/scp.SCPClient
        """
        try:
            ssh = SSHClient()
            ssh.load_system_host_keys()
            ssh.connect(hostname=config.remote_system_ip)
            self.copy_crashes_dir_with_scp(ssh)
        except AuthenticationException:
            print("Authentication failed, please verify your credentials: %s")
        except SSHException as sshException:
            print("Unable to establish SSH connection: %s" % sshException)
        except BadHostKeyException as badHostKeyException:
            print("Unable to verify server's host key: %s" % badHostKeyException)
        finally:
            ssh.close() 
Example #2
Source File: paramiko_helper.py    From galaxia with Apache License 2.0 6 votes vote down vote up
def loginandcopy(hostname,uname,pwd,sfile,tfile):
     try:
        log.info("Establishing ssh connection")
        client = getsshClient()
        client.load_system_host_keys()
        client.connect(hostname)#,username=uname)#,password=pwd)
     except paramiko.AuthenticationException:
        print("Authentication failed, please verify your credentials: %s")
     except paramiko.SSHException as sshException:
        print("Unable to establish SSH connection: %s" % sshException)
     except paramiko.BadHostKeyException as badHostKeyException:
        print("Unable to verify server's host key: %s" % badHostKeyException)
     except Exception as e:
        print(e.args)
     try:
        log.info("Getting SCP Client")
        scpclient = scp.SCPClient(client.get_transport())
        log.info(scpclient)
        log.info("Hostname: %s", hostname)
        log.info("source file: %s", sfile)
        log.info("target file: %s", tfile)
        scpclient.put(sfile,tfile)
     except scp.SCPException as e:
        print("Operation error: %s", e) 
Example #3
Source File: cmdshell.py    From canvas with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def connect(self):
        retry = 0
        while retry < 5:
            try:
                self._ssh_client.connect(self.server.hostname,
                                         username=self.uname,
                                         pkey=self._pkey)
                return
            except socket.error, (value,message):
                if value == 61 or value == 111:
                    print 'SSH Connection refused, will retry in 5 seconds'
                    time.sleep(5)
                    retry += 1
                else:
                    raise
            except paramiko.BadHostKeyException:
                print "%s has an entry in ~/.ssh/known_hosts and it doesn't match" % self.server.hostname
                print 'Edit that file to remove the entry and then hit return to try again'
                raw_input('Hit Enter when ready')
                retry += 1 
Example #4
Source File: paramiko_helper.py    From galaxia with Apache License 2.0 6 votes vote down vote up
def loginandcopydir(hostname,uname,pwd,sfile,tfile,recursive,preserve_times):
     try:
        log.info("Establishing ssh connection")
        client = getsshClient()
        client.load_system_host_keys()
        client.connect(hostname) #,username=uname)#,password=pwd)
     except paramiko.AuthenticationException:
        print("Authentication failed, please verify your credentials: %s")
     except paramiko.SSHException as sshException:
        print("Unable to establish SSH connection: %s" % sshException)
     except paramiko.BadHostKeyException as badHostKeyException:
        print("Unable to verify server's host key: %s" % badHostKeyException)
     except Exception as e:
        print(e.args)
     try:
        scpclient = scp.SCPClient(client.get_transport())
        scpclient.put(sfile,tfile,recursive,preserve_times)
     except scp.SCPException as e:
        print("Operation error: %s", e)

# Deprecated 
Example #5
Source File: paramiko_helper.py    From galaxia with Apache License 2.0 6 votes vote down vote up
def loginandrun(hostname,uname,pwd,command):
     try:
        log.info("Establishing ssh connection")
        client = getsshClient()
        client.load_system_host_keys()
        client.connect(hostname)#,username=uname)#,password=pwd)
     except paramiko.AuthenticationException:
        print("Authentication failed, please verify your credentials: %s")
     except paramiko.SSHException as sshException:
        print("Unable to establish SSH connection: %s" % sshException)
     except paramiko.BadHostKeyException as badHostKeyException:
        print("Unable to verify server's host key: %s" % badHostKeyException)
     try:
        stdin, stdout, stderr = client.exec_command(command)
        result = stderr.read()
        if len(result)  > 0:
            print("hit error" + result)

     except Exception as e:
        print("Operation error: %s", e)


# Any new implementation to use this method 
Example #6
Source File: handler.py    From webssh with MIT License 6 votes vote down vote up
def ssh_connect(self, args):
        ssh = self.ssh_client
        dst_addr = args[:2]
        logging.info('Connecting to {}:{}'.format(*dst_addr))

        try:
            ssh.connect(*args, timeout=options.timeout)
        except socket.error:
            raise ValueError('Unable to connect to {}:{}'.format(*dst_addr))
        except paramiko.BadAuthenticationType:
            raise ValueError('Bad authentication type.')
        except paramiko.AuthenticationException:
            raise ValueError('Authentication failed.')
        except paramiko.BadHostKeyException:
            raise ValueError('Bad host key.')

        term = self.get_argument('term', u'') or u'xterm'
        chan = ssh.invoke_shell(term=term)
        chan.setblocking(0)
        worker = Worker(self.loop, ssh, chan, dst_addr)
        worker.encoding = options.encoding if options.encoding else \
            self.get_default_encoding(ssh)
        return worker 
Example #7
Source File: main.py    From chain with Apache License 2.0 6 votes vote down vote up
def ssh_connect(self):
        ssh = paramiko.SSHClient()
        ssh._system_host_keys = self.settings['system_host_keys']
        ssh._host_keys = self.settings['host_keys']
        ssh.set_missing_host_key_policy(self.settings['policy'])

        args = self.get_args()
        dst_addr = (args[0], args[1])
        logging.info('Connecting to {}:{}'.format(*dst_addr))

        try:
            ssh.connect(*args, timeout=6)
        except socket.error:
            raise ValueError('Unable to connect to {}:{}'.format(*dst_addr))
        except paramiko.BadAuthenticationType:
            raise ValueError('Authentication failed.')
        except paramiko.BadHostKeyException:
            raise ValueError('Bad host key.')

        chan = ssh.invoke_shell(term='xterm')
        chan.setblocking(0)
        worker = Worker(ssh, chan, dst_addr)
        IOLoop.current().call_later(DELAY, recycle, worker)
        return worker 
Example #8
Source File: policy.py    From webssh with MIT License 5 votes vote down vote up
def is_missing_host_key(self, client, hostname, key):
        k = client._system_host_keys.lookup(hostname) or \
                client._host_keys.lookup(hostname)
        if k is None:
            return True
        host_key = k.get(key.get_name(), None)
        if host_key is None:
            return True
        if host_key != key:
            raise paramiko.BadHostKeyException(hostname, key, host_key) 
Example #9
Source File: test_policy.py    From webssh with MIT License 5 votes vote down vote up
def test_is_missing_host_key(self):
        client = paramiko.SSHClient()
        file1 = make_tests_data_path('known_hosts_example')
        file2 = make_tests_data_path('known_hosts_example2')
        client.load_host_keys(file1)
        client.load_system_host_keys(file2)

        autoadd = AutoAddPolicy()
        for f in [file1, file2]:
            entry = paramiko.hostkeys.HostKeys(f)._entries[0]
            hostname = entry.hostnames[0]
            key = entry.key
            self.assertIsNone(
                autoadd.is_missing_host_key(client, hostname, key)
            )

        for f in [file1, file2]:
            entry = paramiko.hostkeys.HostKeys(f)._entries[0]
            hostname = entry.hostnames[0]
            key = entry.key
            key.get_name = lambda: 'unknown'
            self.assertTrue(
                autoadd.is_missing_host_key(client, hostname, key)
            )
        del key.get_name

        for f in [file1, file2]:
            entry = paramiko.hostkeys.HostKeys(f)._entries[0]
            hostname = entry.hostnames[0][1:]
            key = entry.key
            self.assertTrue(
                autoadd.is_missing_host_key(client, hostname, key)
            )

        file3 = make_tests_data_path('known_hosts_example3')
        entry = paramiko.hostkeys.HostKeys(file3)._entries[0]
        hostname = entry.hostnames[0]
        key = entry.key
        with self.assertRaises(paramiko.BadHostKeyException):
            autoadd.is_missing_host_key(client, hostname, key) 
Example #10
Source File: connections.py    From python-gvm with GNU General Public License v3.0 5 votes vote down vote up
def connect(self):
        """
        Connect to the SSH server and authenticate to it
        """
        self._socket = paramiko.SSHClient()
        self._socket.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        try:
            self._socket.connect(
                hostname=self.hostname,
                username=self.username,
                password=self.password,
                timeout=self._timeout,
                port=int(self.port),
                allow_agent=False,
                look_for_keys=False,
            )
            self._stdin, self._stdout, self._stderr = self._socket.exec_command(
                "", get_pty=False
            )

        except (
            paramiko.BadHostKeyException,
            paramiko.AuthenticationException,
            paramiko.SSHException,
        ) as e:
            raise GvmError("SSH Connection failed", e) 
Example #11
Source File: ShellScriptHandler.py    From simoorg with Apache License 2.0 5 votes vote down vote up
def connect(self):
        """
            Connect to the given hostname, using the provided credentials
            Args:
                None
            Return:
                None
            Raise:
                paramiko.BadHostKeyException: if host key is not readable
                paramiko.AuthenticationException: if authentication failed

        """
        try:
            self.ssh_client.connect(self.hostname, port=self.port,
                                    username=self.username,
                                    password=self.password, pkey=self.pkey,
                                    key_filename=self.key_filename,
                                    timeout=self.connect_timeout,
                                    allow_agent=self.allow_agent,
                                    look_for_keys=self.look_for_keys)
        except paramiko.BadHostKeyException:
            print "[FATAL]: Server's host key could not be retrieved"
            raise
        except paramiko.AuthenticationException:
            print "[FATAL]: Authentication failed"
            raise
        except Exception, exc:
            print ("Unknown exception while connecting to server: ",
                   self.hostname, exc)
            raise 
Example #12
Source File: cmdshell.py    From aws-extender with MIT License 5 votes vote down vote up
def connect(self, num_retries=5):
        """
        Connect to an SSH server and authenticate with it.
        
        :type num_retries: int
        :param num_retries: The maximum number of connection attempts.
        """
        retry = 0
        while retry < num_retries:
            try:
                self._ssh_client.connect(self.server.hostname,
                                         username=self.uname,
                                         pkey=self._pkey,
                                         timeout=self._timeout)
                return
            except socket.error as xxx_todo_changeme:
                (value, message) = xxx_todo_changeme.args
                if value in (51, 61, 111):
                    print('SSH Connection refused, will retry in 5 seconds')
                    time.sleep(5)
                    retry += 1
                else:
                    raise
            except paramiko.BadHostKeyException:
                print("%s has an entry in ~/.ssh/known_hosts and it doesn't match" % self.server.hostname)
                print('Edit that file to remove the entry and then hit return to try again')
                raw_input('Hit Enter when ready')
                retry += 1
            except EOFError:
                print('Unexpected Error from SSH Connection, retry in 5 seconds')
                time.sleep(5)
                retry += 1
        print('Could not establish SSH connection') 
Example #13
Source File: ssh.py    From power-up with Apache License 2.0 5 votes vote down vote up
def exec_cmd(self, ip_addr, username, password, cmd,
                 ssh_log=False, look_for_keys=True, key_filename=None):
        self.ssh_log = SSH_LOG
        if ssh_log and logger.is_log_level_file_debug():
            paramiko.util.log_to_file(self.ssh_log)

        ssh = paramiko.SSHClient()
        ssh.load_system_host_keys()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        try:
            ssh.connect(
                ip_addr,
                port=self.SWITCH_PORT,
                username=username,
                password=password,
                look_for_keys=look_for_keys,
                key_filename=key_filename)
        except (
                paramiko.BadHostKeyException,
                paramiko.AuthenticationException,
                paramiko.SSHException,
                socket.error,
                BaseException) as exc:
            self.log.error('%s: %s' % (ip_addr, str(exc)))
            raise SSH_Exception('SSH connection Failure - {}'.format(exc))
            # sys.exit(1)
        try:
            _, stdout, stderr = ssh.exec_command(cmd)
        except paramiko.SSHException as exc:
            self.log.error('%s: %s, %s' % (ip_addr, str(exc), stderr.read()))
            sys.exit(1)
        stdout_ = stdout.read()
        stderr_ = stderr.read()
        status = stdout.channel.recv_exit_status()
        ssh.close()
        return status, stdout_, stderr_ 
Example #14
Source File: ssh.py    From power-up with Apache License 2.0 5 votes vote down vote up
def __init__(self, host, ssh_log=False, username=None,
                 password=None, look_for_keys=True, key_filename=None):
        paramiko.SSHClient.__init__(self)
        self.host = host
        self.log = logger.getlogger()
        self.ssh_log = SSH_LOG
        if ssh_log and logger.is_log_level_file_debug():
            paramiko.util.log_to_file(self.ssh_log)

        if key_filename is None:
            self.load_system_host_keys()
        self.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        try:
            self.connect(
                host,
                username=username,
                password=password,
                look_for_keys=look_for_keys,
                key_filename=key_filename)
        except (
                paramiko.BadHostKeyException,
                paramiko.AuthenticationException,
                paramiko.SSHException,
                socket.error,
                BaseException) as exc:
            self.log.error('%s: %s' % (host, str(exc)))
            raise SSH_Exception('Connection Failure - {}'.format(exc)) 
Example #15
Source File: test_policy.py    From adminset with GNU General Public License v2.0 5 votes vote down vote up
def test_is_missing_host_key(self):
        client = paramiko.SSHClient()
        file1 = make_tests_data_path('known_hosts_example')
        file2 = make_tests_data_path('known_hosts_example2')
        client.load_host_keys(file1)
        client.load_system_host_keys(file2)

        autoadd = AutoAddPolicy()
        for f in [file1, file2]:
            entry = paramiko.hostkeys.HostKeys(f)._entries[0]
            hostname = entry.hostnames[0]
            key = entry.key
            self.assertIsNone(
                autoadd.is_missing_host_key(client, hostname, key)
            )

        for f in [file1, file2]:
            entry = paramiko.hostkeys.HostKeys(f)._entries[0]
            hostname = entry.hostnames[0]
            key = entry.key
            key.get_name = lambda: 'unknown'
            self.assertTrue(
                autoadd.is_missing_host_key(client, hostname, key)
            )
        del key.get_name

        for f in [file1, file2]:
            entry = paramiko.hostkeys.HostKeys(f)._entries[0]
            hostname = entry.hostnames[0][1:]
            key = entry.key
            self.assertTrue(
                autoadd.is_missing_host_key(client, hostname, key)
            )

        file3 = make_tests_data_path('known_hosts_example3')
        entry = paramiko.hostkeys.HostKeys(file3)._entries[0]
        hostname = entry.hostnames[0]
        key = entry.key
        with self.assertRaises(paramiko.BadHostKeyException):
            autoadd.is_missing_host_key(client, hostname, key) 
Example #16
Source File: policy.py    From adminset with GNU General Public License v2.0 5 votes vote down vote up
def is_missing_host_key(self, client, hostname, key):
        k = client._system_host_keys.lookup(hostname) or \
                client._host_keys.lookup(hostname)
        if k is None:
            return True
        host_key = k.get(key.get_name(), None)
        if host_key is None:
            return True
        if host_key != key:
            raise paramiko.BadHostKeyException(hostname, key, host_key) 
Example #17
Source File: handler.py    From adminset with GNU General Public License v2.0 5 votes vote down vote up
def ssh_connect(self):
        ssh = self.ssh_client

        try:
            args = self.get_args()
        except InvalidValueError as exc:
            raise tornado.web.HTTPError(400, str(exc))

        dst_addr = (args[0], args[1])
        logging.info('Connecting to {}:{}'.format(*dst_addr))

        try:
            ssh.connect(*args, timeout=6)
        except socket.error:
            raise ValueError('Unable to connect to {}:{}'.format(*dst_addr))
        except paramiko.BadAuthenticationType:
            raise ValueError('Bad authentication type.')
        except paramiko.AuthenticationException:
            raise ValueError('Authentication failed.')
        except paramiko.BadHostKeyException:
            raise ValueError('Bad host key.')

        chan = ssh.invoke_shell(term='xterm')
        chan.setblocking(0)
        worker = Worker(self.loop, ssh, chan, dst_addr, self.src_addr)
        worker.encoding = self.get_default_encoding(ssh)
        return worker 
Example #18
Source File: vpn_utils.py    From neutron-vpnaas with Apache License 2.0 5 votes vote down vote up
def execute_cmd_over_ssh(host, cmd, private_key):
    """Run the given command over ssh

    Using paramiko package, it creates a connection to the given host;
    executes the required command on it and returns the output.
    :param host: Dictionary of ip, username and password
    :param cmd: Command to be run over ssh
    :param private_key: path to private key file
    :return: Output of the executed command
    """
    LOG.debug('EXECUTE COMMAND <%s> OVER SSH', cmd)
    client = paramiko.SSHClient()
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    k = paramiko.RSAKey.from_private_key_file(private_key)

    try:

        client.connect(host["ip"], username=host["username"], pkey=k)
    except paramiko.BadHostKeyException as e:
        raise Exception(
            "BADHOSTKEY EXCEPTION WHEN CONNECTING TO %s", host["ip"], e)
    except paramiko.AuthenticationException as e:
        raise Exception(
            "AUTHENTICATION EXCEPTION WHEN CONNECTING TO %s", host["ip"], e)
    except paramiko.SSHException as e:
        raise Exception("SSH EXCEPTION WHEN CONNECTING TO %s", host["ip"], e)
    except socket.error as e:
        raise Exception("SOCKET ERROR WHEN CONNECTING TO %s", host["ip"], e)
    LOG.debug("CONNECTED TO HOST <%s>", host["ip"])
    try:
        stdin, stdout, stderr = client.exec_command(cmd)
        return stdout.read().splitlines()
    except paramiko.SSHException as e:
        raise Exception("SSHEXCEPTION WHEN CONNECTING TO %s", host["ip"], e)
    finally:
        client.close() 
Example #19
Source File: test_client.py    From python-hpedockerplugin with Apache License 2.0 5 votes vote down vote up
def _client_host_key_bad(self, host_key):
        threading.Thread(target=self._run).start()
        hostname = '[%s]:%d' % (self.addr, self.port)

        self.tc = paramiko.SSHClient()
        self.tc.set_missing_host_key_policy(paramiko.WarningPolicy())
        known_hosts = self.tc.get_host_keys()
        known_hosts.add(hostname, host_key.get_name(), host_key)

        self.assertRaises(
            paramiko.BadHostKeyException,
            self.tc.connect,
            password='pygmalion',
            **self.connect_kwargs
        ) 
Example #20
Source File: conn_manager.py    From appetite with Apache License 2.0 4 votes vote down vote up
def get_ssh_client(hostname, ssh_hostname):
        """Tries to create ssh client

        Create ssh client based on the username and ssh key
        """

        if not CREDS.SSH_KEYFILE:
            logger.errorout("ssh_keyfile not set",
                            module=COMMAND_MODULE_CUSTOM)

        retries = 0

        while retries < MAX_SSH_RETRIES:
            try:
                ssh = paramiko.SSHClient()
                ssh.load_system_host_keys()
                ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

                ssh.connect(hostname=ssh_hostname,
                            username=CREDS.SSH_USER,
                            port=CREDS.SSH_PORT,
                            pkey=CREDS.PK,
                            timeout=CONNECTION_TIMEOUT)

                return ssh
            except paramiko.BadAuthenticationType:
                logger.error("BadAuthenticationType",
                             hostname=hostname,
                             module=COMMAND_MODULE_CUSTOM)
                return
            except paramiko.AuthenticationException:
                logger.error("Authentication failed",
                             hostname=hostname,
                             module=COMMAND_MODULE_CUSTOM)
                return
            except paramiko.BadHostKeyException:
                logger.error("BadHostKeyException",
                             fix="Edit known_hosts file to remove the entry",
                             hostname=hostname,
                             module=COMMAND_MODULE_CUSTOM)
                return
            except paramiko.SSHException:
                logger.error("SSHException",
                             hostname=hostname,
                             module=COMMAND_MODULE_CUSTOM)
                return
            except Exception as e:
                if retries == 0:
                    logger.error("Problems connecting to host",
                                 hostname=hostname,
                                 module=COMMAND_MODULE_CUSTOM,
                                 error=e.message)
                retries += 1
                time.sleep(1)

        logger.error("Can not connect to host",
                     hostname=hostname,
                     module=COMMAND_MODULE_CUSTOM)

        return None 
Example #21
Source File: vpn_utils.py    From neutron-vpnaas with Apache License 2.0 4 votes vote down vote up
def write_key_to_compute_node(keypair, local_path, remote_path, host,
                              private_key):
    """Write the private key of the nova instance to the compute node

    First fetches the private key from the keypair and writes it to a
    temporary file in the local machine. It then sftp's the file
    to the compute host.

    :param keypair: nova keypair
    :param local_path: path to private key file of the nova instance in the
                       local machine
    :param remote_path: path where the private key file has to be placed
                        in the remote machine
    :param host: compute host credentials
    :param private_key: path to your private key file
    :return:
    """

    LOG.debug("WRITING PRIVATE KEY TO COMPUTE NODE")
    k = paramiko.RSAKey.from_private_key_file(private_key)
    write_key_to_local_path(keypair, local_path)
    try:
        transport = paramiko.Transport(host['ip'], host['port'])
    except paramiko.SSHException as e:
        raise Exception(
            "PARAMIKO TRANSPORT FAILED. CHECK IF THE HOST IP %s AND PORT %s "
            "ARE CORRECT %s", host['ip'], host['port'], e)
    try:
        transport.connect(
                username=host['username'], pkey=k)
    except paramiko.BadHostKeyException as e:
        transport.close()
        raise Exception(
            "BADHOSTKEY EXCEPTION WHEN CONNECTING TO %s", host["ip"], e)
    except paramiko.AuthenticationException as e:
        transport.close()
        raise Exception("AUTHENTICATION EXCEPTION WHEN CONNECTING TO %s",
                        host["ip"], e)
    except paramiko.SSHException as e:
        transport.close()
        raise Exception("SSH EXCEPTION WHEN CONNECTING TO %s", host["ip"], e)
    LOG.debug("CONNECTED TO HOST <%s>", host["ip"])

    try:
        sftp_client = paramiko.SFTPClient.from_transport(transport)
        sftp_client.put(local_path, remote_path)
    except IOError as e:
        raise Exception("FILE PATH DOESN'T EXIST", e)
    finally:
        transport.close() 
Example #22
Source File: ssh_il.py    From parsl with Apache License 2.0 4 votes vote down vote up
def __init__(self, hostname, username=None, password=None, script_dir=None, envs=None):
        ''' Initialize a persistent connection to the remote system.
        We should know at this point whether ssh connectivity is possible

        Args:
            - hostname (String) : Hostname

        KWargs:
            - username (string) : Username on remote system
            - password (string) : Password for remote system
            - script_dir (string) : Full path to a script dir where
              generated scripts could be sent to.
            - envs (dict) : A dictionary of env variables to be set when executing commands

        Raises:
        '''
        self.hostname = hostname
        self.username = username
        self.password = password

        self.ssh_client = paramiko.SSHClient()
        self.ssh_client.load_system_host_keys()
        self.ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        self.script_dir = script_dir

        self.envs = {}
        if envs is not None:
            self.envs = envs

        try:
            self.ssh_client.connect(
                hostname, username=username, password=password, allow_agent=True
            )

        except Exception:
            logger.debug("Caught the SSHException in SSHInteractive")
            pass
        '''
        except paramiko.BadHostKeyException as e:
            raise BadHostKeyException(e, self.hostname)

        except paramiko.AuthenticationException as e:
            raise AuthException(e, self.hostname)

        except paramiko.SSHException as e:
            logger.debug("Caught the SSHException in SSHInteractive")
            pass

        except Exception as e:
            raise SSHException(e, self.hostname)
        '''

        transport = self.ssh_client.get_transport()

        il_password = getpass.getpass('Enter {0} Logon password :'.format(hostname))
        transport.auth_password(username, il_password)

        self.sftp_client = paramiko.SFTPClient.from_transport(transport)