Let say I have a file /home/user/dir1/file.txt
on a remote SFTP server. I want to copy this file to lets say /home/user/dir2/file.txt
, while I am i
Not sure what you mean by the "command". Are you referring to an SFTP protocol request? Or a command of some scriptable/command-line SFTP client (e.g. the OpenSSH sftp
)?
The SFTP protocol on its own does not allow duplication of a remote file. Though there's an optional extension of the protocol named copy-file
that serves the purpose.
Quoting the copy-file extension specification:
6. Copying Remote Files
byte SSH_FXP_EXTENDED uint32 request-id string "copy-file" string source-file string destination-file bool overwrite-destination
This request copies a file from one location to another on the server. The server responds with SSH_FXP_STATUS.
Not many SFTP servers support the extension though. I know that ProFTPD/mod_sftp and Bitvise WinSSHD do. Notably, the OpenSSH does not (neither the server, nor the sftp
client).