使用paramiko在windows下批量登陆linux服务器

使用paramiko在windows下批量登陆linux服务器

环境:

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]

在windows上安装paramiko模块

在windows上安装paramiko模块

环境:

windows8.1 X86_64  

需求:

Python中使用SSH需要用到OpenSSH,而OpenSSH依赖于paramiko模块,而paramiko模块又依赖于   pycrypto模块,因此要在Python中使用SSH。所以我们需要先安装pycrypto工具,然后再安装paramiko模块才能使用。  
安装Parmiko首先要保证Python 已经安装完成。  
PS:	linux的安装相对简单,只需要下载安装就OK  
[Read More]