# -*- 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()
时间: 2024-12-29 10:12:35