如何使用 SFTP 将文件复制/复制到另一个目录? [英] How can I copy/duplicate a file to another directory using SFTP?

查看:1128
本文介绍了如何使用 SFTP 将文件复制/复制到另一个目录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 SFTP 位置创建了一个目录,我想将文件从一个 SFTP 目录移动到另一个目录,但那里不支持 cp 命令.

I have created a directory within an SFTP location and I want to move a file from one SFTP directory to another directory but cp command is not supported there.

我怎样才能做到这一点?

How can I achieve this?

推荐答案

核心 SFTP 协议不支持复制远程文件.

The core SFTP protocol does not support duplicating a remote file.

copy-file 的草稿 协议的扩展.但只有少数 SFTP 服务器(ProFTPD/mod_sftp 和 Bitvise SFTP 服务器支持)例如)和少数 SFTP 客户端(例如WinSCP).

There's draft of copy-file extension to the protocol. But that's supported by only few SFTP servers (ProFTPD/mod_sftp and Bitvise SFTP server for example) and few SFTP clients (WinSCP for example).

最广泛使用的 OpenSSH SFTP 服务器绝对不支持它.也不是 OpenSSH SFTP 客户端(sftp),即没有 cp 命令或任何其他功能等效的命令.

It's definitely not supported by the most widespread OpenSSH SFTP server. Nor by OpenSSH SFTP client (sftp), i.e. there's no cp command or any other functionally equivalent.

替代方案:

  • 如果您可以通过 SSH/终端访问服务器,请使用 shell cp 命令.
  • 如果您的 SFTP 服务器支持 copy-file 扩展,请使用也支持它的 SFTP 客户端.
  • 否则,您唯一的选择是将文件下载到本地临时位置并将其副本上传回不同的/目标远程目录.
    一些 SFTP 客户端甚至可以一次性为您执行此操作(例如在 WinSCP 中,请参阅重复对话框).
  • If you have SSH/terminal access into the server, use the shell cp command.
  • If your SFTP server supports the copy-file extension, use an SFTP client that supports it too.
  • Otherwise, your only option is to download the file to a local temporary location and upload its copy back to a different/target remote directory.
    Some SFTP clients can do this for you even transparently in one go (e.g. in WinSCP, see Duplicate via local temporary copy option on Duplicate dialog).

(我是 WinSCP 的作者)

这篇关于如何使用 SFTP 将文件复制/复制到另一个目录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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