当前位置: 首页>>代码示例>>Python>>正文


Python paramiko.AuthenticationException方法代码示例

本文整理汇总了Python中paramiko.AuthenticationException方法的典型用法代码示例。如果您正苦于以下问题:Python paramiko.AuthenticationException方法的具体用法?Python paramiko.AuthenticationException怎么用?Python paramiko.AuthenticationException使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在paramiko的用法示例。


在下文中一共展示了paramiko.AuthenticationException方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: fetch_remote_crashes

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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() 
开发者ID:fkie-cad,项目名称:LuckyCAT,代码行数:19,代码来源:RemoteCrashFetcher.py

示例2: connect

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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() 
开发者ID:kd8bny,项目名称:LiMEaide,代码行数:27,代码来源:network.py

示例3: _try_passwordless_paramiko

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:23,代码来源:tunnel.py

示例4: _try_passwordless_paramiko

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:23,代码来源:tunnel.py

示例5: test_connectivity

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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 
开发者ID:grycap,项目名称:im,代码行数:27,代码来源:SSH.py

示例6: attempt

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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 
开发者ID:PacktPublishing,项目名称:Effective-Python-Penetration-Testing,代码行数:23,代码来源:ssh-brute-force-threded.py

示例7: execute

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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) 
开发者ID:ThreatResponse,项目名称:margaritashotgun,代码行数:25,代码来源:remote_shell.py

示例8: execute_async

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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) 
开发者ID:ThreatResponse,项目名称:margaritashotgun,代码行数:26,代码来源:remote_shell.py

示例9: ssh_connect

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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 
开发者ID:huashengdun,项目名称:webssh,代码行数:25,代码来源:handler.py

示例10: _try_passwordless_paramiko

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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 
开发者ID:korniichuk,项目名称:rk,代码行数:24,代码来源:tunnel.py

示例11: do_ssh

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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) 
开发者ID:d3vilbug,项目名称:Brutal_SSH,代码行数:18,代码来源:brutal_SSH.py

示例12: loginandrun

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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 
开发者ID:WiproOpenSource,项目名称:galaxia,代码行数:25,代码来源:paramiko_helper.py

示例13: loginandcopydir

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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 
开发者ID:WiproOpenSource,项目名称:galaxia,代码行数:23,代码来源:paramiko_helper.py

示例14: loginandcopy

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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) 
开发者ID:WiproOpenSource,项目名称:galaxia,代码行数:26,代码来源:paramiko_helper.py

示例15: check_sshBF

# 需要导入模块: import paramiko [as 别名]
# 或者: from paramiko import AuthenticationException [as 别名]
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 
开发者ID:Quantika14,项目名称:Shodita,代码行数:20,代码来源:gigante-ssh-bot.py


注:本文中的paramiko.AuthenticationException方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。