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, )
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, )
def _connect_ssh(ip): return network.connect_ssh( ip, SSH_USER, SSH_PASSWORD, client=CiscoSSHClient, )
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): if not settings.SSH_PASSWORD: raise Error('no password defined') return network.connect_ssh( ip, settings.SSH_USER or 'root', settings.SSH_PASSWORD, )
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, )
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, )
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, )
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, )
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
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)
def _connect_ssh(ip): return network.connect_ssh(ip, SSH_MSA_USER, SSH_MSA_PASSWORD, client=storageworks.HPSSHClient)
def _connect_ssh(ip, username='******', password=''): return network.connect_ssh(ip, 'root', settings.SSH_PASSWORD)
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)
def _connect_ssh(ip): return network.connect_ssh(ip, SSH_P2000_USER, SSH_P2000_PASSWORD, client=storageworks.HPSSHClient)
def _connect_ssh(ip): return network.connect_ssh(ip, settings.SSH_SSG_USER, settings.SSH_SSG_PASSWORD, client=SSGSSHClient)
def _connect_ssh(ip): return network.connect_ssh(ip, XEN_USER, XEN_PASSWORD)
def _connect_ssh(ip, username='******', password=''): return network.connect_ssh(ip, SSH_USER, SSH_PASS, client=CiscoSSHClient)
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)
def _connect_ssh(ip): return network.connect_ssh(ip, AIX_USER, AIX_PASSWORD, key=AIX_KEY)
def _connect_ssh(ip): return network.connect_ssh(ip, SSH_P2000_USER, SSH_P2000_PASSWORD, client=HPSSHClient)
def _connect_ssh(ip, username="******", password=""): return network.connect_ssh(ip, "root", settings.SSH_PASSWORD)
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)
def _connect_ssh(ip): return network.connect_ssh(ip, SSH_3PAR_USER, SSH_3PAR_PASSWORD)
def _connect_ssh(ip): return network.connect_ssh(ip, SSH_ONSTOR_USER, SSH_ONSTOR_PASSWORD)
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)