How to transfer a file to ssh server in an ssh

I am using Python's paramiko packet to keep an ssh-connection with an server :

s = paramiko.SSHClient()
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
s.connect("xxx.xxx.xxx.xxx",22,username=xxx,password='',timeout=4)

I want to use this ssh-connection to transfer a file to ssh server, how can i do?

Just like use scp a-file xxx@xxx.xxx.xxx.xxx:filepath command?


尝试这个:

s = paramiko.SSHClient()
s.set_missing_host_key_policy(paramiko.AutoAddPolicy())
s.connect("xxx.xxx.xxx.xxx",22,username=xxx,password='',timeout=4)

sftp = s.open_sftp()
sftp.put('/home/me/file.ext', '/remote/home/file.ext')
链接地址: http://www.djcxy.com/p/33640.html

上一篇: 为Paramiko模块的sftp.get()设置时间限制

下一篇: 如何在ssh中将文件传输到ssh服务器