环境:
windows8.1 X86_64
被测试的机器:
192.168.100.228,192.168.100.240
脚本如下:
#!/bin/env python
import paramiko
import os
import datetime
from ConfigParser import ConfigParser
ConfigFile = 'ipaddr.txt'
config = ConfigParser()
config.read(ConfigFile)
hostname1=''.join(config.get('IP','ipaddr'))
address=hostname1.split(';')
print address
username = 'root'
password = '123456'
port = 22
if __name__=="__main__":
for ip in address:
paramiko.util.log_to_file('paramiko-ssh1.log')
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect(hostname=ip,username=username,password=password)
stdin,stdout,stderr=ssh.exec_command('ifconfig eth0;free -m')
print stdout.read()
ssh.close()
[Read More]