码迷,mamicode.com
首页 > 其他好文 > 详细

paramiko模块远程案例

时间:2018-08-29 18:41:29      阅读:146      评论:0      收藏:0      [点我收藏+]

标签:ssi   utf-8   word   auto   bin   cep   paramik   hal   shc   

#!/usr/bin/python
#coding: utf-8

import paramiko
#iphosts=["192.168.10.70","192.168.10.71","192.168.10.72","192.168.10.73","192.168.10.74","192.168.10.75","192.168.10.76","192.168.11.50","192.168.11.40","192.168.11.41","192.168.11.42","192.168.11.43","192.168.11.44","192.168.11.45","192.168.11.48","192.168.11.49"]
#usernames=["halo_op","wifi","root"]
#ports=["22","1080"]
#passwords=["wifikey","maMuptoFodN","hLQIhMoV","KipyoYVq","mvCPdhdi","KWE7gegz"]
ip = [‘192.168.221.206‘,‘192.168.221.205‘]
port = [22,21]
username = [‘root‘,‘username‘]
password = [‘wsw‘,‘sdf‘,‘520157000‘]
def connection(ip,port,username,password):
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(i,o,p,q)
stdin, stdout, stderr = ssh.exec_command(‘hostname‘)
print stdout.read()
ssh.close()

if name == ‘main‘:

connection(ip,port,username,password)

count = 0
for i in ip:
    for o in port:
        for p in username:
            for q in password:
                print i
                print o
                print p
                print q
                try:
                    connection(i,o,p,q)
                    count += 1
                    print "wwwwwwwwwwwwwwww %s"%count
                except Exception as a:
                    print a

count += 1

print count

paramiko模块远程案例

标签:ssi   utf-8   word   auto   bin   cep   paramik   hal   shc   

原文地址:http://blog.51cto.com/13945009/2166122

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!