Ejemplo n.º 1
0
def ssh(ip,port,username,password,command):
    try:
        ssh = paramiko.SSHClient()
        ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
        ssh.connect(ip,port,username,password,timeout=9)
        __stdin, stdout, __stderr = ssh.exec_command(command)
        out = stdout.readlines()
        return platform.linesep.join(out)
        print '%s\tOK\n'%(ip)
        ssh.close()
    except:
        print '%s\tError\n'%(ip)
        tb.print_exc()