码迷,mamicode.com
首页 > 编程语言 > 详细

python ssh连接

时间:2014-10-11 17:02:35      阅读:256      评论:0      收藏:0      [点我收藏+]

标签:style   blog   color   os   ar   sp   div   on   log   

import paramiko

def
fw_exec(self, command): def fw_exec(self, command): FW_USER = ‘‘ FW_PASSWD = ‘‘ FW_HOST = ‘‘ paramiko.util.log_to_file(paramiko_log.txt) ssh=paramiko.SSHClient() ssh.load_system_host_keys() ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy()) ssh.connect(FW_HOST,port=22,username=FW_USER,password=FW_PASSWD,compress=True) stdin, stdout, stderr = ssh.exec_command(command) logtxt = stdout.read() print logtxt ssh.close()gtxt ssh.close()

 

python ssh连接

标签:style   blog   color   os   ar   sp   div   on   log   

原文地址:http://www.cnblogs.com/DDSys/p/4019071.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!