The core SFTP protocol does not support duplicating a remote file.
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).
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.
Alternatives:
- 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).
(I'm the author of WinSCP)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…