Python paramiko.AuthenticationException() Examples

The following are 30 code examples of paramiko.AuthenticationException(). 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: network.py    From LiMEaide with GNU General Public License v3.0 9 votes vote down vote up
def connect(self):
        """Call to set connection with remote client."""

        try:
            self.paramiko_session = paramiko.SSHClient()
            self.paramiko_session.set_missing_host_key_policy(
                paramiko.AutoAddPolicy())

            self.paramiko_session.connect(
                self.client.ip, username=self.client.user,
                password=self.client.pass_, key_filename=self.client.key,
                allow_agent=True, compress=self.client.compress)

        except (paramiko.AuthenticationException,
                paramiko.ssh_exception.NoValidConnectionsError) as e:
            self.logger.error(e)
            sys.exit(colored("> {}".format(e), 'red'))

        except paramiko.SSHException as e:
            self.logger.error(e)
            sys.exit(colored("> {}".format(e), 'red'))

        self.transfer = network.Network(
            self.paramiko_session, self.client.ip, self.client.port)
        self.transfer.open() 
Example #3
Source File: tunnel.py    From Computable with MIT License 8 votes vote down vote up
def _try_passwordless_paramiko(server, keyfile):
    """Try passwordless login with paramiko."""
    if paramiko is None:
        msg = "Paramiko unavaliable, "
        if sys.platform == 'win32':
            msg += "Paramiko is required for ssh tunneled connections on Windows."
        else:
            msg += "use OpenSSH."
        raise ImportError(msg)
    username, server, port = _split_server(server)
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.WarningPolicy())
    try:
        client.connect(server, port, username=username, key_filename=keyfile,
               look_for_keys=True)
    except paramiko.AuthenticationException:
        return False
    else:
        client.close()
        return True 
Example #4
Source File: tunnel.py    From vnpy_crypto with MIT License 8 votes vote down vote up
def _try_passwordless_paramiko(server, keyfile):
    """Try passwordless login with paramiko."""
    if paramiko is None:
        msg = "Paramiko unavailable, "
        if sys.platform == 'win32':
            msg += "Paramiko is required for ssh tunneled connections on Windows."
        else:
            msg += "use OpenSSH."
        raise ImportError(msg)
    username, server, port = _split_server(server)
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.WarningPolicy())
    try:
        client.connect(server, port, username=username, key_filename=keyfile,
               look_for_keys=True)
    except paramiko.AuthenticationException:
        return False
    else:
        client.close()
        return True 
Example #5
Source File: ssh-brute-force-threded.py    From Effective-Python-Penetration-Testing with MIT License 7 votes vote down vote up
def attempt(Password):

    IP = "127.0.0.1"
    USER = "rejah"
    PORT=22
      
    try:

        ssh = paramiko.SSHClient()
        ssh.load_system_host_keys()
        ssh.set_missing_host_key_policy(paramiko.MissingHostKeyPolicy())
 
        try:
            ssh.connect(IP , port=PORT, username=USER, password=Password)
            print "Connected successfully. Password = "+Password
        except paramiko.AuthenticationException, error:
            print "Incorrect password: "+Password
            pass
        except socket.error, error:
            print error
            pass 
Example #6
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 #7
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 #8
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 #9
Source File: tunnel.py    From pySINDy with MIT License 6 votes vote down vote up
def _try_passwordless_paramiko(server, keyfile):
    """Try passwordless login with paramiko."""
    if paramiko is None:
        msg = "Paramiko unavailable, "
        if sys.platform == 'win32':
            msg += "Paramiko is required for ssh tunneled connections on Windows."
        else:
            msg += "use OpenSSH."
        raise ImportError(msg)
    username, server, port = _split_server(server)
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.WarningPolicy())
    try:
        client.connect(server, port, username=username, key_filename=keyfile,
               look_for_keys=True)
    except paramiko.AuthenticationException:
        return False
    else:
        client.close()
        return True 
Example #10
Source File: ssh.py    From brute with MIT License 6 votes vote down vote up
def brute(self, username, pwd_guess) -> int:
        """
        Throw int status instead of a string response to
        dictate success/failure during authentication.
        """

        status = 0
        try:
            self.client.connect(
                self.address, port=self.port, username=username, password=pwd_guess
            )
        except paramiko.AuthenticationException:
            status = -1

        self.client.close()
        return status 
Example #11
Source File: tunnel.py    From Carnets with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
def _try_passwordless_paramiko(server, keyfile):
    """Try passwordless login with paramiko."""
    if paramiko is None:
        msg = "Paramiko unavailable, "
        if sys.platform == 'win32':
            msg += "Paramiko is required for ssh tunneled connections on Windows."
        else:
            msg += "use OpenSSH."
        raise ImportError(msg)
    username, server, port = _split_server(server)
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    client.set_missing_host_key_policy(paramiko.WarningPolicy())
    try:
        client.connect(server, port, username=username, key_filename=keyfile,
               look_for_keys=True)
    except paramiko.AuthenticationException:
        return False
    else:
        client.close()
        return True 
Example #12
Source File: gigante-ssh-bot.py    From Shodita with GNU General Public License v3.0 6 votes vote down vote up
def check_sshBF(ip):
	print colores.HEADER + "[*][TARGET] SSH connect to " + ip + colores.normal
	paramiko.util.log_to_file("filename.log")
	fail = 0
	user="root"
	for p in passwords:
		ssh = paramiko.SSHClient()
		ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
		try:
			print colores.verde + "|----[INFO] Try user: root password: " + p + colores.normal
			ssh.connect(ip, username=user, password=p, timeout=10)
		except paramiko.AuthenticationException, error:
			print "|----[ERROR] incorrect password... root@" + ip + ":" + p
			continue
		except socket.error, error:
			fail += 1
			print error
			continue 
Example #13
Source File: remote_shell.py    From margaritashotgun with MIT License 6 votes vote down vote up
def execute_async(self, command, callback=None):
        """
        Executes command on remote hosts without blocking

        :type command: str
        :param command: command to be run on remote host
        :type callback: function
        :param callback: function to call when execution completes
        """
        try:
            logger.debug(('{0}: execute async "{1}"'
                          'with callback {2}'.format(self.target_address,
                                                     command,
                                                     callback)))
            future = self.executor.submit(self.execute, command)
            if callback is not None:
                future.add_done_callback(callback)
            return future
        except (AuthenticationException, SSHException,
                ChannelException, SocketError) as ex:
            logger.critical(("{0} execution failed on {1} with exception:"
                             "{2}".format(command, self.target_address,
                                               ex)))
            raise SSHCommandError(self.target_address, command, ex) 
Example #14
Source File: remote_shell.py    From margaritashotgun with MIT License 6 votes vote down vote up
def execute(self, command):
        """
        Executes command on remote hosts

        :type command: str
        :param command: command to be run on remote host
        """
        try:
            if self.ssh.get_transport() is not None:
                logger.debug('{0}: executing "{1}"'.format(self.target_address,
                                                           command))
                stdin, stdout, stderr = self.ssh.exec_command(command)
                return dict(zip(['stdin', 'stdout', 'stderr'],
                                [stdin, stdout, stderr]))
            else:
                raise SSHConnectionError(self.target_address,
                                         "ssh transport is closed")
        except (AuthenticationException, SSHException,
                ChannelException, SocketError) as ex:
            logger.critical(("{0} execution failed on {1} with exception:"
                             "{2}".format(command, self.target_address,
                                               ex)))
            raise SSHCommandError(self.target_address, command, ex) 
Example #15
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 #16
Source File: brutal_SSH.py    From Brutal_SSH with MIT License 6 votes vote down vote up
def do_ssh(self, username):
		while not self.passwords.empty():
			time.sleep(0.1)
			password = self.passwords.get()
			ssh = paramiko.SSHClient()
			ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
			try:
				ssh.connect(self.host_ip, port=self.host_port, username=username, password=password, timeout=self.timeout)
				print info_out + ffb + "{} : {:.<50} {}".format(username, password, fgb + "Successful" + sf)
				ssh.close(); exit(0)
			except paramiko.AuthenticationException:
				print ver_out + ffb + "{} : {:.<50} {}".format(username, password, frb + "Failed" + sf)
			except socket.error, e:
				print err_out + ffb + "{} : {:.<50} {}".format(username, password, fcb + "Connection Failed" + sf)
			except paramiko.SSHException: 
				print err_out + ffb + "{} : {:.<50} {}".format(username, password, fbb + "Error" + sf) 
Example #17
Source File: minisftp.py    From iOSSecAudit with GNU General Public License v3.0 6 votes vote down vote up
def sftp_conn(self):
        """"""
        try:
            self.transport = paramiko.Transport((self.host, self.port)) 
            self.transport.connect(username = self.username, password = self.password) 
            self.sftp = paramiko.SFTPClient.from_transport(self.transport)
            return True
        except paramiko.AuthenticationException:
            G.log(G.ERROR, "SFTP Authentication failed when connecting to %s" % self.host)
            return False
        except:
            G.log(G.ERROR, "SFTP Could not SSH to %s, waiting for it to start" % self.host)
            return False

    
    #---------------------------------------------------------------------- 
Example #18
Source File: tunnel.py    From rk with The Unlicense 6 votes vote down vote up
def _try_passwordless_paramiko(server, keyfile):
    """Try passwordless login with paramiko."""
    if paramiko is None:
        msg = "Paramiko unavaliable, "
        if sys.platform == 'win32':
            msg += "Paramiko is required for ssh tunneled connections on Windows."
        else:
            msg += "use OpenSSH."
        raise ImportError(msg)
    username, server, port = _split_server(server)
    client = paramiko.SSHClient()
    client.load_system_host_keys()
    #client.set_missing_host_key_policy(paramiko.WarningPolicy())
    client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    try:
        client.connect(server, port, username=username, key_filename=keyfile,
               look_for_keys=True)
    except paramiko.AuthenticationException:
        return False
    else:
        client.close()
        return True 
Example #19
Source File: SSH.py    From im with GNU General Public License v3.0 6 votes vote down vote up
def test_connectivity(self, time_out=None):
        """ Tests if the SSH is active

            Arguments:
            - time_out: Timeout to connect.

            Returns: True if the connection is established or False otherwise

            Raises:
                Exception
        """
        try:
            client, proxy = self.connect(time_out)
            client.close()
            if proxy:
                proxy.close()
            return True
        except paramiko.AuthenticationException:
            raise AuthenticationException("Authentication Error!!")
        except paramiko.SSHException as e:
            if str(e) == "No authentication methods available":
                raise AuthenticationException("Authentication Error!!")
            return False
        except Exception:
            return False 
Example #20
Source File: module_solaris.py    From nix_bsd_mac_inventory with MIT License 5 votes vote down vote up
def connect(self):
        try:
            if not self.use_key_file:
                self.ssh.connect(str(self.machine_name), port=self.port, username=self.username, password=self.password,
                                 timeout=self.timeout)
            else:
                self.ssh.connect(str(self.machine_name), port=self.port, username=self.username,
                                 key_filename=self.key_file, timeout=self.timeout)
        except paramiko.AuthenticationException:
            print str(self.machine_name) + ': authentication failed'
            return None
        except Exception as err:
            print str(self.machine_name) + ': ' + str(err)
            return None 
Example #21
Source File: test_magics.py    From sshkernel with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def test_login_with_exception_set_retval(self):
        self.kernel.do_login = Mock(side_effect=AuthenticationException)

        self.instance.line_login("dummy")
        self.assertIsNotNone(self.instance.retval) 
Example #22
Source File: SSHConnection_brute_force.py    From Mastering-Python-for-Networking-and-Security with MIT License 5 votes vote down vote up
def ssh_connect(self,ip,user,password,code=0):
		self.ssh.load_system_host_keys()
		self.ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
		print("[*] Testing user and password from dictionary")
		print("[*] User: %s" %(user))
		print("[*] Pass :%s" %(password))
		try:
			self.ssh.connect(ip,port=22,username=user,password=password,timeout=5)
		except paramiko.AuthenticationException:
			code = 1
		except socket.error as e:
			code = 2
		self.ssh.close()
		return code 
Example #23
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 #24
Source File: main.py    From PyNode with MIT License 5 votes vote down vote up
def connect(self):
        while True:
            try:
                log('Trying to connect to server')
                self.ssh.connect(self.server_ip_addr, port=22, username='root', password=self.server_pw, timeout=5)
                log('Connected to server')
                break
            except (paramiko.AuthenticationException, Exception):
                log('Couldnt connect to host yet. Its probably not started yet. Will retry in 20s. This is normal.')
                sleep(20)
        return True 
Example #25
Source File: ssh.py    From xscontainer with BSD 2-Clause "Simplified" License 5 votes vote down vote up
def prepare_ssh_client(session, vmuuid):
    username = api_helper.get_vm_xscontainer_username(session, vmuuid)
    host = api_helper.get_suitable_vm_ip(session, vmuuid, SSH_PORT)
    log.info("prepare_ssh_client for vm %s, via %s@%s"
             % (vmuuid, username, host))
    client = paramiko.SSHClient()
    pkey = paramiko.rsakey.RSAKey.from_private_key(
        StringIO.StringIO(api_helper.get_idrsa_secret_private(session)))
    client.get_host_keys().clear()
    client.set_missing_host_key_policy(MyHostKeyPolicy(session, vmuuid))
    try:
        client.connect(host, port=SSH_PORT, username=username,
                       pkey=pkey, look_for_keys=False, banner_timeout=300)
    except SshException:
        # This exception is already improved - leave it as it is
        raise
    except paramiko.AuthenticationException as exception:
        message = ("prepare_ssh_client failed to authenticate with private key"
                   " on VM %s" % (vmuuid))
        log.info(message)
        raise AuthenticationException(message)
    except (paramiko.SSHException, socket.error) as exception:
        # reraise as SshException
        raise SshException("prepare_ssh_client: %s" % exception,
                           (sys.exc_info()[2]))
    return client 
Example #26
Source File: sftpstorage.py    From django-storages with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
def _connect(self):
        self._ssh = paramiko.SSHClient()

        known_host_file = self._known_host_file or os.path.expanduser(
            os.path.join("~", ".ssh", "known_hosts")
        )

        if os.path.exists(known_host_file):
            self._ssh.load_host_keys(known_host_file)

        # and automatically add new host keys for hosts we haven't seen before.
        self._ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

        try:
            self._ssh.connect(self._host, **self._params)
        except paramiko.AuthenticationException as e:
            if self._interactive and 'password' not in self._params:
                # If authentication has failed, and we haven't already tried
                # username/password, and configuration allows it, then try
                # again with username/password.
                if 'username' not in self._params:
                    self._params['username'] = getpass.getuser()
                self._params['password'] = getpass.getpass()
                self._connect()
            else:
                raise paramiko.AuthenticationException(e)

        if self._ssh.get_transport():
            self._sftp = self._ssh.open_sftp() 
Example #27
Source File: cmd_executer.py    From tacker with Apache License 2.0 5 votes vote down vote up
def __connect(self):
        try:
            self.__ssh = paramiko.SSHClient()
            self.__ssh.set_missing_host_key_policy(paramiko.WarningPolicy())
            self.__ssh.connect(self.__host, username=self.__user,
                password=self.__password, timeout=self.__timeout)
            LOG.info("Connected to %s", self.__host)
        except paramiko.AuthenticationException:
            LOG.error("Authentication failed when connecting to %s",
                      self.__host)
            raise exceptions.NotAuthorized
        except paramiko.SSHException:
            LOG.error("Could not connect to %s. Giving up", self.__host)
            raise 
Example #28
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 #29
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 #30
Source File: centos_bootstrap.py    From aeon-ztps with Apache License 2.0 5 votes vote down vote up
def wait_for_device(self, countdown, poll_delay):

        dev = None

        # first we need to wait for the device to be 'reachable' via the API.
        # we'll use the probe error to detect if it is or not

        while not dev:
            msg = 'reload-countdown at: {} seconds'.format(countdown)
            self.post_device_status(message=msg, state='AWAIT-ONLINE')
            self.log.info(msg)

            try:
                dev = Device(self.target, user=self.user, passwd=self.passwd,
                             timeout=poll_delay)

            except AuthenticationException as e:
                self.log.info('Authentication exception reported: {} \n args: {}'.format(e, e.args))
                self.exit_results(results=dict(
                    ok=False,
                    error_type='login',
                    message='Unauthorized - check user/password'))

            except NoValidConnectionsError as e:
                countdown -= poll_delay
                if countdown <= 0:
                    self.exit_results(results=dict(
                        ok=False,
                        error_type='login',
                        message='Failed to connect to target %s within reload countdown' % self.target))

                time.sleep(poll_delay)

        self.dev = dev
        self.post_device_facts()

    # ##### -----------------------------------------------------------------------
    # #####
    # #####                           OS install process
    # #####
    # ##### -----------------------------------------------------------------------