Python学习笔记-SSH连接


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

import os
import paramiko 

host = '192.168.10.10'
port = 22
username = 'Hadoop'
password = 'hadoop'

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()

《Python核心编程 第二版》.(Wesley J. Chun ).[高清PDF中文版]

《Python开发技术详解》.( 周伟,宗杰).[高清PDF扫描版+随书视频+代码]

Python脚本获取Linux系统信息

在Ubuntu下用Python搭建桌面算法交易研究环境

Python 的详细介绍:请点这里
Python 的下载地址:请点这里

本文永久更新链接地址:

相关内容