python 多线程远程执行命令
来源:互联网 发布:js中的unicode编码表 编辑:程序博客网 时间:2024/06/05 15:44
如题,代码如下:
import paramiko,threading,sys,time,osclass SSHThread(threading.Thread): def __init__(self, ip, port,user,pwd,timeout,cmd): threading.Thread.__init__(self) self.ip = ip self.port = port self.user = user self.pwd = pwd self.timeout = timeout self.cmd = cmd self.LogFile = "/home/linxw/temp/test.log" def run(self): print("Start try ssh => %s" % self.ip) try: ssh = paramiko.SSHClient() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(self.ip, self.port, username=self.user, password=self.pwd, timeout=self.timeout) print("[%s] Login %s => %s " % (self.ip, self.user, self.pwd)) open(self.LogFile, "a").write("[ %s ] IP => %s, port => %d, %s => %s" % (time.asctime( time.localtime(time.time()) ), self.ip, self.port, self.user, self.pwd)) print("[%s] exec : %s" % (self.ip,self.cmd)) open(self.LogFile,"a").write("[%s] exec : %s" % (self.ip,self.cmd)) stdin,stdout,stderr = ssh.exec_command(self.cmd) print("[%s] exec result : %s" % (self.ip,stdout.read())) return True except: print("[%s] Error %s => %s" % (self.ip, self.user, self.pwd)) open(self.LogFile, "a").write("[%s] Error %s => %s" % (self.ip, self.user, self.pwd)) return Falsedef ViolenceSSH(ip, port,user,pwd,timeout,cmd): ssh_scan = SSHThread(ip, port, user, pwd, timeout,cmd) ssh_scan.start()if __name__ == '__main__': ipList = ['192.168.163.128','127.0.0.1'] for ip in ipList: threading.Thread(target = ViolenceSSH, args = (ip, 22,'root','1234',3,'uptime' )).start()
阅读全文
2 0
- python 多线程远程执行命令
- 利用python多线程执行远程linux上命令
- Python远程执行Linux命令
- Python ssh 远程执行shell命令
- python 利用pexpect进行多机远程命令执行
- python模块paramiko的上传下载和远程执行命令方法
- python 利用pexpect进行多机远程命令执行
- python ssh2远程登录节点并执行命令
- python利用paramiko连接远程服务器执行命令
- python模块paramiko的上传下载和远程执行命令方法
- Python实现SSH远程登陆,并执行远程命令
- python socket c/s远程命令执行案例
- python telnet远程登录端口交互执行命令
- python paramiko模块实现远程文件上传文件, 执行命令
- 通过python socket远程执行命令,并返回值
- Python:通过Socket让远程电脑执行某些命令
- python 使用ssh远程登录并执行命令返回结果
- ssh 远程执行命令
- ueditor iframe被过滤掉问题,优酷视频链接
- iOS利用HealthKit获取健康里的步数和睡眠时间
- 对项目的一点思考
- 图像特征
- Mysql源码包的编译安装手册
- python 多线程远程执行命令
- oracle一张表向另一张表插入不重复数据merge into用法
- 决策树
- FastJson--阿里巴巴公司开源的速度最快的Json和对象转换工具
- HDU 2089 解题报告 数位DP
- es6字符串扩展(三)
- (搬运).net起步 (MemberShip 初步实例)
- 写Wireshark CORBA插件,来分析CORBA RPC
- 关于接口里面的方法的调用