1,使用到Python的paramiko模块
2,下面直接上代码
import paramiko
localpath =r'/tmp/a.txt' remotepath = r'/mnt/b.txt'
t = paramiko.Transport((ip,ssh_port)) t.connect(username="your login username",password="you password") sftp =paramiko.SFTPClient.from_transport(t)
#download file sft.get(remotepath,localpath) #upload file sft.put(localpath,remotepath)
sft.close()