标签:style blog http io color ar os sp 文件
模拟远程执行命令:
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
import paramiko#设置日志记录paramiko.util.log_to_file(‘/tmp/test‘)#建立连接ssh=paramiko.SSHClient()#缺失host_knows时的处理方法ssh.load_system_host_keys()ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())#连接远程客户机器ssh.connect(‘10.1.6.190‘,port=22,username=‘root‘,password=‘password‘,compress=True)#获取远程命令执行结果stdin, stdout, stderr = ssh.exec_command(‘hostname;uptime‘)print stdout.read()# 其中其他各类的提示在stderr,#输出执行结果ssh.close()模拟远程文件传输:
|
标签:style blog http io color ar os sp 文件
原文地址:http://www.cnblogs.com/wipy/p/4094308.html