Skip to main content
Welcome guest. | Register | Login | Post

CLI file transfer over SSH

Copy a file to host:
cat FILE|ssh HOST "cat ->FILE'S-LOCATION-ON-HOST"

Copy a file from a host to current host:
ssh HOST "cat FILE"|cat ->FILE'S-LOCATION-ON-CURRENT-HOST

Comments

scp file host:filescp

scp file host:file
scp host:file file

to copy multiple files at once, scp -r works, but

tar cf - FILES | ssh host tar xvf -
ssh host tar cf - FILES | tar xvf -

is common. On slow connections, you can combine this with compression, e.g. add a 'j' or 'z' option.

For compression you could

For compression you could also use the -C option of ssh or scp. This is gzip compression, like the z option of tar. If you want gzip compression, scp -r -C probably is faster than the tar trick.

rsync

I usually use rsync. I can xfer an entire directory structure and only the needed files (changed) are sent over the line.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.