Paramiko

paramiko

 

 

#!/usr/bin/python 

import paramiko

 

t = paramiko.Transport((“主机”,”端口”))

t.connect(username = “用户名”, password = “口令”)

sftp = paramiko.SFTPClient.from_transport(t)

remotepath=’/var/log/system.log’

localpath=’/tmp/system.log’

sftp.put(localpath,remotepath)

t.close()

 

 

 

#!/usr/bin/python 

import paramiko

 

ssh = paramiko.SSHClient()

ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

ssh.connect("某IP地址",22,"用户名", "口令")

stdin, stdout, stderr = ssh.exec_command("你的命令")

print stdout.readlines()

ssh.close()

你可能感兴趣的:(param)