根据需求下载相关文件到指定的局域网内机器

import paramiko


def put_file(machinename, username, password, dirname, filename, data):
    ssh = paramiko.SSHClient()
    ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
    ssh.connect(machinename, username=username, password=password)
    sftp = ssh.open_sftp()
    # try:
    #     sftp.mkdir(dirname)
    # except IOError:
    #     pass
    f = sftp.open(dirname + '/' + filename, 'w')
    f.write(data)
    f.close()
    ssh.close()


data = 'This is arbitrary data\n'
put_file('192.168.1.169', '账号', '密码', '/data4/lubaogui/pdf_bak', 'file.bin', data)