Exemplo n.º 1
0
def ssh_linux(**kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    kwargs['guessmodel'] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
    if gmodel not in {'Linux', 'ESX', 'XEN'}:
        return False, 'no match: %s %s' % (gvendor, gmodel), kwargs
    ip = str(kwargs['ip'])
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    ssh = None
    auths = [
        (settings.SSH_USER or 'root', settings.SSH_PASSWORD),
        (settings.XEN_USER, settings.XEN_PASSWORD),
    ]
    try:
        for user, password in auths:
            if user is None or password is None:
                continue
            try:
                ssh = network.connect_ssh(ip, user, password)
            except network.AuthError:
                pass
            else:
                break
        else:
            return False, 'Authorization failed', kwargs
        name = run_ssh_linux(ssh, ip)
    except (network.Error, paramiko.SSHException) as e:
        return False, str(e), kwargs
    return True, name, kwargs
def _connect_ssh(ip):
    return network.connect_ssh(
        ip,
        settings.SSH_IBM_USER,
        settings.SSH_IBM_PASSWORD,
        client=IBMSSHClient,
    )
Exemplo n.º 3
0
def _connect_ssh(ip):
    return network.connect_ssh(
        ip,
        settings.SSH_IBM_USER,
        settings.SSH_IBM_PASSWORD,
        client=IBMSSHClient,
    )
Exemplo n.º 4
0
def _connect_ssh(ip):
    return network.connect_ssh(
        ip,
        settings.SCAN_PLUGINS.get(__name__, {})['ssh_ibm_user'],
        settings.SCAN_PLUGINS.get(__name__, {})['ssh_ibm_password'],
        client=IBMSSHClient,
    )
Exemplo n.º 5
0
def ssh_linux(**kwargs):
    if 'nx-os' in kwargs.get('snmp_name', '').lower():
        return False, 'incompatible Nexus found.', kwargs
    kwargs['guessmodel'] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
    if gmodel not in {'Linux', 'ESX', 'XEN'}:
        return False, 'no match: %s %s' % (gvendor, gmodel), kwargs
    ip = str(kwargs['ip'])
    if not network.check_tcp_port(ip, 22):
        return False, 'closed.', kwargs
    ssh = None
    auths = [
        (settings.SSH_USER or 'root', settings.SSH_PASSWORD),
        (settings.XEN_USER, settings.XEN_PASSWORD),
    ]
    try:
        for user, password in auths:
            if user is None or password is None:
                continue
            try:
                ssh = network.connect_ssh(ip, user, password)
            except network.AuthError:
                pass
            else:
                break
        else:
            return False, 'Authorization failed', kwargs
        name = run_ssh_linux(ssh, ip)
    except (network.Error, paramiko.SSHException) as e:
        return False, str(e), kwargs
    return True, name, kwargs
Exemplo n.º 6
0
def _connect_ssh(ip):
    return network.connect_ssh(
        ip,
        settings.SCAN_PLUGINS.get(__name__, {})['ssh_ibm_user'],
        settings.SCAN_PLUGINS.get(__name__, {})['ssh_ibm_password'],
        client=IBMSSHClient,
    )
Exemplo n.º 7
0
def _connect_ssh(ip):
    return network.connect_ssh(
        ip,
        SSH_USER,
        SSH_PASSWORD,
        client=CiscoSSHClient,
    )
Exemplo n.º 8
0
def ssh_linux(**kwargs):
    if "nx-os" in kwargs.get("snmp_name", "").lower():
        return False, "incompatible Nexus found.", kwargs
    kwargs["guessmodel"] = gvendor, gmodel = guessmodel.guessmodel(**kwargs)
    if gmodel not in {"Linux", "ESX", "XEN"}:
        return False, "no match: %s %s" % (gvendor, gmodel), kwargs
    ip = str(kwargs["ip"])
    if not network.check_tcp_port(ip, 22):
        return False, "closed.", kwargs
    ssh = None
    auths = [(settings.SSH_USER or "root", settings.SSH_PASSWORD), (settings.XEN_USER, settings.XEN_PASSWORD)]
    try:
        for user, password in auths:
            if user is None or password is None:
                continue
            try:
                ssh = network.connect_ssh(ip, user, password)
            except network.AuthError:
                pass
            else:
                break
        else:
            return False, "Authorization failed", kwargs
        name = run_ssh_linux(ssh, ip)
    except (network.Error, paramiko.SSHException) as e:
        return False, str(e), kwargs
    return True, name, kwargs
Exemplo n.º 9
0
def _connect_ssh(ip):
    if not settings.SSH_PASSWORD:
        raise Error('no password defined')
    return network.connect_ssh(
        ip,
        settings.SSH_USER or 'root',
        settings.SSH_PASSWORD,
    )
Exemplo n.º 10
0
def _connect_ssh(ip):
    if not settings.SSH_PASSWORD:
        raise Error('no password defined')
    return network.connect_ssh(
        ip,
        settings.SSH_USER or 'root',
        settings.SSH_PASSWORD,
    )
Exemplo n.º 11
0
def _connect_ssh(ip_address, user, password):
    if not network.check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed on a HP MSA Storage.')
    return network.connect_ssh(
        ip_address,
        user,
        password,
        client=HPSSHClient,
    )
Exemplo n.º 12
0
def _connect_ssh(ip_address, user, password):
    if not network.check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed on a HP MSA Storage.')
    return network.connect_ssh(
        ip_address,
        user,
        password,
        client=HPSSHClient,
    )
Exemplo n.º 13
0
def _connect_ssh(ip, username, password):
    if not network.check_tcp_port(ip, 22):
        raise ConnectionError('Port 22 closed.')
    return network.connect_ssh(
        ip,
        username,
        password,
        client=CiscoSSHClient,
    )
Exemplo n.º 14
0
def _connect_ssh(ip):
    if not network.check_tcp_port(ip, 22):
        raise ConnectionError('Port 22 closed.')
    return network.connect_ssh(
        ip,
        SSH_USER,
        SSH_PASSWORD,
        client=CiscoSSHClient,
    )
Exemplo n.º 15
0
def _connect_ssh(ip):
    SETTINGS = settings.SCAN_PLUGINS.get(__name__, {})
    SSH_USER, SSH_PASSWORD = SETTINGS['ssh_user'], SETTINGS['ssh_password']
    if not SSH_PASSWORD:
        raise NotConfiguredError(
            "ssh not configured in plugin {}".format(__name__), )
    return network.connect_ssh(
        ip,
        SSH_USER or 'root',
        SSH_PASSWORD,
    )
Exemplo n.º 16
0
def _connect_ssh(ip):
    SETTINGS = settings.SCAN_PLUGINS.get(__name__, {})
    SSH_USER, SSH_PASSWORD = SETTINGS['ssh_user'], SETTINGS['ssh_password']
    if not SSH_PASSWORD:
        raise NotConfiguredError(
            "ssh not configured in plugin {}".format(__name__),
        )
    return network.connect_ssh(
        ip,
        SSH_USER or 'root',
        SSH_PASSWORD,
    )
Exemplo n.º 17
0
def scan_address(ip_address, **kwargs):
    messages = []
    result = get_base_result_template('ssh_linux', messages)
    snmp_name = kwargs.get('snmp_name', '') or ''
    if not snmp_name:
        raise NoMatchError("No snmp found")
    snmp_name = snmp_name.lower()
    if 'nx-os' in snmp_name:
        messages.append('Incompatible Nexus found.')
        result['status'] = 'error'
        return result
    if all((
            'linux' not in snmp_name,
            'xen' not in snmp_name,
            not snmp_name.startswith('vmware esx'),
    )):
        messages.append('No match.')
        result['status'] = 'error'
        return result
    ssh = None
    auths = SETTINGS.get('auths', [])
    for user, password in auths:
        if user is None or password is None:
            continue
        try:
            ssh = network.connect_ssh(ip_address, user, password)
        except network.AuthError:
            continue
        else:
            break
    if not ssh:
        messages.append('Authorization failed')
        result['status'] = 'error'
        return result
    try:
        device_info = _ssh_linux(ssh, ip_address)
    except (network.Error, paramiko.SSHException) as e:
        messages.append(unicode(e))
        result['status'] = 'error'
    else:
        result.update({
            'status': 'success',
            'device': device_info,
        })
    return result
Exemplo n.º 18
0
def scan_address(ip_address, **kwargs):
    messages = []
    result = get_base_result_template('ssh_linux', messages)
    snmp_name = kwargs.get('snmp_name', '') or ''
    if not snmp_name:
        raise NoMatchError("No snmp found")
    snmp_name = snmp_name.lower()
    if 'nx-os' in snmp_name:
        messages.append('Incompatible Nexus found.')
        result['status'] = 'error'
        return result
    if all((
        'linux' not in snmp_name,
        'xen' not in snmp_name,
        not snmp_name.startswith('vmware esx'),
    )):
        messages.append('No match.')
        result['status'] = 'error'
        return result
    ssh = None
    auths = SETTINGS.get('auths', [])
    for user, password in auths:
        if user is None or password is None:
            continue
        try:
            ssh = network.connect_ssh(ip_address, user, password)
        except network.AuthError:
            continue
        else:
            break
    if not ssh:
        messages.append('Authorization failed')
        result['status'] = 'error'
        return result
    try:
        device_info = _ssh_linux(ssh, ip_address)
    except (network.Error, paramiko.SSHException) as e:
        messages.append(unicode(e))
        result['status'] = 'error'
    else:
        result.update({
            'status': 'success',
            'device': device_info,
        })
    return result
Exemplo n.º 19
0
def _connect_ssh(ip_address, user, password):
    if not check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed on a XEN server.')
    return connect_ssh(ip_address, user, password)
Exemplo n.º 20
0
def _connect_ssh(ip):
    return network.connect_ssh(ip, SSH_MSA_USER, SSH_MSA_PASSWORD,
                               client=storageworks.HPSSHClient)
Exemplo n.º 21
0
def _connect_ssh(ip, username='******', password=''):
    return network.connect_ssh(ip, 'root', settings.SSH_PASSWORD)
Exemplo n.º 22
0
def _connect_ssh(ip_address, user, password):
    if not network.check_tcp_port(ip_address, 22):
        raise ConnectionError("Port 22 closed on a Proxmox server.")
    return network.connect_ssh(ip_address, user, password)
Exemplo n.º 23
0
def _connect_ssh(ip):
    return network.connect_ssh(ip, SSH_P2000_USER, SSH_P2000_PASSWORD,
                               client=storageworks.HPSSHClient)
Exemplo n.º 24
0
def _connect_ssh(ip):
    return network.connect_ssh(ip, settings.SSH_SSG_USER,
            settings.SSH_SSG_PASSWORD, client=SSGSSHClient)
Exemplo n.º 25
0
def _connect_ssh(ip):
    return network.connect_ssh(
        ip, SSH_USER, SSH_PASSWORD, client=CiscoSSHClient,
    )
Exemplo n.º 26
0
def _connect_ssh(ip):
    return network.connect_ssh(ip, XEN_USER, XEN_PASSWORD)
Exemplo n.º 27
0
def _connect_ssh(ip_address, user, password):
    if not check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed on a XEN server.')
    return connect_ssh(ip_address, user, password)
Exemplo n.º 28
0
def _connect_ssh(ip, username='******', password=''):
    return network.connect_ssh(ip, SSH_USER, SSH_PASS, client=CiscoSSHClient)
Exemplo n.º 29
0
def _connect_ssh(ip_address, user, password):
    if not check_tcp_port(ip_address, 22):
        raise ConnectionError("Port 22 closed on a Juniper switch.")
    return connect_ssh(ip_address, user, password)
Exemplo n.º 30
0
def _connect_ssh(ip, username='******', password=''):
    return network.connect_ssh(ip, 'root', settings.SSH_PASSWORD)
Exemplo n.º 31
0
def _connect_ssh(ip):
    if not network.check_tcp_port(ip, 22):
        raise ConnectionError('Port 22 closed.')
    return network.connect_ssh(
        ip, SSH_USER, SSH_PASSWORD, client=CiscoSSHClient,
    )
Exemplo n.º 32
0
def _connect_ssh(ip, username='******', password=''):
    return network.connect_ssh(ip, SSH_USER, SSH_PASS, client=CiscoSSHClient)
Exemplo n.º 33
0
def _connect_ssh(ip):
    return network.connect_ssh(ip, AIX_USER, AIX_PASSWORD, key=AIX_KEY)
Exemplo n.º 34
0
def _connect_ssh(ip):
    return network.connect_ssh(ip,
                               settings.SSH_SSG_USER,
                               settings.SSH_SSG_PASSWORD,
                               client=SSGSSHClient)
Exemplo n.º 35
0
def _connect_ssh(ip):
    return network.connect_ssh(ip,
                               SSH_P2000_USER,
                               SSH_P2000_PASSWORD,
                               client=HPSSHClient)
Exemplo n.º 36
0
def _connect_ssh(ip):
    return network.connect_ssh(ip, XEN_USER, XEN_PASSWORD)
Exemplo n.º 37
0
def _connect_ssh(ip, username="******", password=""):
    return network.connect_ssh(ip, "root", settings.SSH_PASSWORD)
Exemplo n.º 38
0
def _connect_ssh(ip):
    return network.connect_ssh(ip, AIX_USER, AIX_PASSWORD, key=AIX_KEY)
Exemplo n.º 39
0
def _connect_ssh(ip_address, user, password):
    if not check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed.')
    return connect_ssh(ip_address, user, password, client=SSGSSHClient)
Exemplo n.º 40
0
def _connect_ssh(ip):
    return network.connect_ssh(ip, SSH_3PAR_USER, SSH_3PAR_PASSWORD)
Exemplo n.º 41
0
def _connect_ssh(ip):
    return network.connect_ssh(ip, SSH_ONSTOR_USER, SSH_ONSTOR_PASSWORD)
Exemplo n.º 42
0
def _connect_ssh(ip, username, password):
    if not network.check_tcp_port(ip, 22):
        raise ConnectionError('Port 22 closed.')
    return network.connect_ssh(
        ip, username, password, client=CiscoSSHClient,
    )
Exemplo n.º 43
0
def _connect_ssh(ip_address, user, password):
    if not network.check_tcp_port(ip_address, 22):
        raise ConnectionError('Port 22 closed on a Proxmox server.')
    return network.connect_ssh(ip_address, user, password)