dennnnnis

导航

paramiko__摘抄

# -*- coding:utf-8 -*-
# Author: Dennis Huang
__Author__ = "Dennis"


import paramiko

# ssh = parammiko.SSHClient()
# ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# ssh.connect(host="192.168.12.12",port = 22,username = "aaa",password = "aaa")
#
#
# ## stdout和stderr,只有一个有结果,另一个为空
# stdin,stdout,stderr = ssh.exec_command("df")
#
# result = stdout.read()

hostname = "192.168.12.12"
transport = paramiko.Transport((hostname,22))
transport.connect(username = "aa",password = "aa")


sftp = paramiko.SFTPClient.from_transport(transport)

sftp.put('/tmp/aaa.txt','/tmp/bbb.txt')

sftp.get('/tmp/aaa.txt','/tmp/bbb.txt')
transport.close()

posted on 2017-08-30 22:22  dennnnnis  阅读(105)  评论(0编辑  收藏  举报