0 votes
by (160 points)
edited

Hi,

I need to copy (not move) a file from one location on an SFTP server to another location on the same SFTP server. I found this answer for the FTP component but the SFTP component does not have the CopyToAnotherServer method. How would I achieve this?

EDIT: Answered in 7 minutes - thanks Lukas!

Applies to: Rebex SFTP

1 Answer

+1 vote
by (147k points)
edited
 
Best answer

Unfortunately, the SFTP protocol doesn't have a "copy" command and it doesn't even support server-to-server transfers, which could be used with FTP to achieve this.

However, SFTP runs over an SSH channel, which means it might be possible to take advantage of SSH remote exec functionality to execute commands at the server. This way, you might be able to execute commands such as "cp sourcepath targetpath" (on Unix-based servers) or "copy soucepath targetpath" (on Windows-based servers) to achieve what you need. Please check out the answer to Remote copy file - SFTP for sample code.

...