I know it's possible to use secure file transfer protocol to transfer files from remote locations to the local box, but is it possible to use it to transfer files from some local directory to another local directory?


If you execute

scp /tmp/a /tmp/b

scp does a real local copy, since both source and target are local paths.

If you try the same with a command line SFTP client, you'll notice that you have to connect to a server before being able to issue commands. Of course it is both possible that you connect to the local server and send a file over the connection without actually leaving the machine and that a given implementation also provides a possibility to effect local copy operations. The former is a bit wasteful, while the latter is definitely implementation dependent.

  • Rsync will do the same given two local paths. – David Pashley Jun 8 '09 at 17:11

You can definitely do this with scp, but I haven't tried this with sftp before. You'll get the most accurate answer by trying it out yourself though.

  • I definitely would've - but the java class that does the transfering needs a fair bit of setting up, so I was wondering if anyone knew the answer off-hand. Thanks though =) – echoblaze Jun 8 '09 at 16:38
  • Oh ok, I thought you were using client/server software rather than a library. – Dana the Sane Jun 8 '09 at 16:40

There's nothing in the protocol to stop that happening no, although your actual code might object, depends on the code you're using I guess.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.