`
fighting_2013
  • 浏览: 14776 次
  • 性别: Icon_minigender_1
社区版块
存档分类
最新评论

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()
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics