设为首页 加入收藏

TOP

Python学习笔记-SSH连接
2014-11-23 22:22:21 来源: 作者: 【 】 浏览:6
Tags:Python 学习 笔记 -SSH 连接

主要是通过paramiko库实现SSH连接功能


import os
import paramiko


ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
private_key_file = os.path.expanduser('C:/Program Files/VMware/VMware Share/id_rsa')
mykey = paramiko.RSAKey.from_private_key_file(private_key_file)
ssh.connect(host, port, username, password, pkey = mykey, timeout = 300)
stdin, stdout, stderr = ssh.exec_command('ls .')
print stdout.read()
ssh.close()


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇Lua学习之字符串函数及模式匹配 下一篇Python学习笔记-简易抓取网页

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: