参考银角大王 :http://www.cnblogs.com/wupeiqi/articles/5095821.html
http://www.cnblogs.com/wupeiqi/articles/5713330.html(pymysql模块)
金角大王:http://www.cnblogs.com/alex3714/articles/5950372.html(python mysql)
http://www.cnblogs.com/alex3714/articles/5978329.html(sqlalchemy ORM)
一、Python的paramiko模块,该模块机遇SSH用于连接远程服务器并执行相关操作
1、SSHClient
用于连接远程服务器并执行基本命令
基于用户名密码连接:
import paramiko ssh = paramiko.SSHClient() # 允许连接不在know_hosts文件中的主机 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(hostname='192.168.4.*',port=22,username='ubuntu',password='******') stdin,stdout,stderr = ssh.exec_command('df -Th') for result in stdout.readlines(): #result = list(filter(lambda x:x is not None,[stdout.read(),stderr.read()]))[0] print(result,end='') ssh.close() transport = paramiko.Transport('192.168.4.*',22) transport.connect(username='ubuntu',password='*******') ssh1 = paramiko.SSHClient() ssh1._transport = transport stdin,stdout,stderr = ssh1.exec_command('ls -l') #result1 = list(filter(lambda x:x is not None,[stdout.read(),stderr.read()])) for result1 in stdout.readlines(): #result = list(filter(lambda x:x is not None,[stdout.read(),stderr.read()]))[0] print(result1,end='') transport.close