如何使用 paramiko 在两个远程服务器之间传输文件? [英] How to use paramiko to transfer files between two remote servers?

查看:79
本文介绍了如何使用 paramiko 在两个远程服务器之间传输文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我如何使用 paramiko 模块在两个远程主机之间传输文件.

我已经看到 'get' 方法会将文件从远程主机获取到本地主机.'put' 方法会将本地文件放到某个远程主机上.

有没有结合'get'和'put'方法的方法,即从远程主机获取文件并将其放入远程主机.此请求将从本地主机发起.

解决方案

Paramiko.sftp_client.SFTPClient 提供 SFTP(安全文件传输协议)功能来在计算机之间移动文件.通过

启动 sftp 会话后

ssh = client.open_sftp(),

您可以访问所有这些方法.>

如果您只想移动远程主机上的文件,那么您可以使用带有 关闭.希望有所帮助!

Please let me know how do I use paramiko module to transfer files between two remote hosts.

I have seen that 'get' method will get the files from remote host to local host. 'put' method will put the local files to some remote host.

Is there any method that combines 'get' and 'put' methods i.e.get files from remote host and put it in remote host. This request will get initiated from localhost.

解决方案

Paramiko.sftp_client.SFTPClient provides SFTP (Secure File Transfer Protocol) features to move files between computers. After starting an sftp session via

ssh = client.open_sftp(),

you can access all of these methods.

If you just want to move files on the remote host, then you can use "local" file transfer methods with shutil. Hope that helped!

这篇关于如何使用 paramiko 在两个远程服务器之间传输文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆