Archived Forum Post

Index of archived forum posts


SFTP Copy File on Server

Aug 27 '16 at 13:29

I am using your SFTP (Secure File Transfer over SSH)

Is there a copy function in your software?

After I upload a file I want to copy it to a backup folder. Is there such a function in your SFTP software?

Obviously I can upload twice, but copying would probably be faster. We have heavy upload volume.


There is nothing in the SFTP protocol itself to do a remote "cp" command to copy a file from one location on the server to another.

You could use SSH run a "cp" command on the server. For example:

success = ssh.SendReqExec(channelNum,"cp filePath1 filePath2");


It should be possible to keep an SSH authenticated connection open for many commands. Each SendReqExec would have to occur on its own logical SSH channel. This means that for each command, one would open a new channel via OpenSessionChannel, send the command, and then receive any output via ChannelReceiveToClose.

Note: The SendReqExec is not a remote shell session. A remote shell session is a bit different, and is demonstrated here:


I use this code. It works if I run "ls", but it cannot run "cp", that's why??


I have the same problem. Maybe it is the config of ssh server?