Transfer file over ssh

datasunny picture datasunny · Mar 25, 2010 · Viewed 17.1k times · Source

In ssh protocol, is there a mechanism for file transfer?
Im working on a existing code base which already has ssh facilities code. Now i need to transfer files over ssh connection. If ssh protocol already support it, i don't have to integrate scp stuff into it.

Thanks.

Edit:
Im using C, ssh code based on openssh.
I have to transfer the file programmingly, not using a external program/command because of some constraints. The program supposed to transfer any size file on remote host chunk-by-chunk, and process the chunk on-the-fly. Then the chunk data is discarded.

Answer

Dom picture Dom · Mar 25, 2010
echo "hello" | ssh user@SSHHost "cat - > /tmp/file"

I juste read the file, pipe it in SSH, and write on the SSHHost server in the /tmp/file.