您的位置:首页 > 其它

paramiko模块远程案例

2018-08-29 17:49 176 查看
#!/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=["hsap","w4rfi","root"]
#ports=["22","1083"]
#passwords=["rteferw","wfwrgrvsf","teet4g","eegteert","fvdgbbdfdt","bbdgbgfg"]
ip = ['192.168.221.206','192.168.221.205']
port = [22,21]
username = ['root','username']
password = ['rete','werwt','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 案例