Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transfer file over ssh

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.

like image 574
datasunny Avatar asked Mar 25 '10 16:03

datasunny


People also ask

Can you transfer files over SSH?

A client can use an SCP to upload files to a remote server safely, download files, or even transfer files via SSH across remote servers.

How do I move a folder over SSH?

Often you will need to move one or more files/folders or copy them to a different location. You can do so using an SSH connection. The commands which you would need to use are mv (short from move) and cp (short from copy). By executing the above command you will move (rename) the file original_file to new_name.

Does scp work over SSH?

The scp command uses SSH to transfer data, so it requires a password or passphrase for authentication. Unlike rcp or FTP, scp encrypts both the file and any passwords exchanged so that anyone snooping on the network cannot view them.


2 Answers

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.

like image 142
Dom Avatar answered Sep 23 '22 13:09

Dom


sftp and scp are both existing "secure" file transfer methods, but your answers are going to depend on what technology stack you are using for your application. You don't mention whether you're using C#, PHP or another language, or what kind of machine your app runs on. These things will have a big bearing on the answers you will get.

like image 21
ZombieSheep Avatar answered Sep 25 '22 13:09

ZombieSheep