In an SFTP session is it possible to copy one remote file to another location on same remote SFTP server?

前端 未结 1 1603
情歌与酒
情歌与酒 2020-12-19 20:07

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

相关标签:
1条回答
  • 2020-12-19 21:01

    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).

    0 讨论(0)
提交回复
热议问题