#!/usr/bin/env python
import paramiko
import os
import sys
#host = sys.argv[1]
#print host
user='root'
password='123456'
port=22
cmd='df -h'
hosts=['192.168.1.234',
'192.168.1.101',
]
s=paramiko.SSHClient()
s.load_system_host_keys()
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
for host in hosts:
s.connect(host,port,user,password,timeout=5)
stdin,stdout,stderr=s.exec_command(cmd)
cmd_result=stdout.read(),stderr.read()
for line in cmd_result:
print line
s.close()
阅读(1266) | 评论(0) | 转发(0) |