def main(): options, server, remote = parse_options() password = None if options.readpass: password = getpass.getpass('Enter SSH password: '******'Connecting to ssh host %s:%d ...' % (server[0], server[1])) try: client.connect(server[0], server[1], username=options.user, key_filename=options.keyfile, look_for_keys=options.look_for_keys, password=password) except Exception, e: print '*** Failed to connect to %s:%d: %r' % (server[0], server[1], e) sys.exit(1)
ti = TclInter('a',{}, logpath=logpath) ti.closeSession() except Exception as e: print(traceback.format_exc()) from IxNetwork import IxNetwork try: ix = IxNetwork('a',{}, logpath=logpath) ix.closeSession() except Exception as e: print(traceback.format_exc()) try: import ssh client = ssh.SSHClient() client.set_missing_host_key_policy(ssh.WarningPolicy()) client.load_system_host_keys() #client.connect('localhost',22, 'user', '1234') chan = client.invoke_shell() except Exception as e: print(traceback.format_exc()) from powershell import powershell try: ps = powershell('a', {}, logpath=logpath) ps.SessionAlive=False except Exception as e: print(traceback.format_exc()) ps.SessionAlive=False
def connect_ssh(ip, private_key_file=None, user='******'): key = ssh.RSAKey.from_private_key_file(private_key_file) client = ssh.SSHClient() client.set_missing_host_key_policy(ssh.WarningPolicy()) client.connect(ip, username=user, pkey=key, timeout=5) return client