Creatively Copying Files over the Network with SSH

Need some simple methods to transfer files? Look here!

If your looking for some simple ways to push and pull your data around without using scp, ftp, nfs, smb or other tools, keep reading! Take a gander below at 18 simple command line Linux/Unix examples for transferring files over the Network securely with SSH.


PUSH Files to another system:


dd if=local_file | ssh target_system dd of=remote_file

cat local_file | ssh target_system cat ">" remote_file

cat local_file | ssh target_system cat - ">" remote_file

tar cvf - . | gzip -c -1 | ssh user@host cat ">" remote_file.gz

ssh target_system cat < local_file " >" remote_file

ssh target_system cat < local_file - " >" remote_file

ssh target_system cat < local_file " | " dd of=remote_file

ssh target_system cat - < local_file " | " dd of=remote_file

( cd SOURCE_DIR && tar cf - . ) | ssh target_system "(cd DESTINATION_DIR && tar xvpf - )"

( cd SOURCE_DIR && tar cvf - . ) | ssh target_system "(cd DESTINATION_DIR && cat - > remote_file.tar )"

( cd SOURCE_DIR && tar czvf - . ) | ssh target_system "(cd DESTINATION_DIR && cat - > remote_file.tgz )"

( cd SOURCE_DIR && tar cvf - . | gzip -1 -) | ssh target_address "(cd DESTINATION_DIR && cat - > remote_file.tgz )"

ssh target_system "( nc -l -p 7777 > remote_file & )" && cat source_file | gzip -1 - | nc target_system 7777

cat local_file | gzip -1 - | ssh target_system cat ">" remote_file.gz

PULL Files from other systems to your location:


ssh target_system cat remote_file > local_file

ssh target_system dd if=remote_file | dd of=local_file

ssh target_system cat "<" remote_file >local_file

ssh target_system cat "<" remote_file.gz | gunzip >local_file

Note: The dash "-" is used to reference either standard input or standard output. The context in which the dash is used is what determines whether it references standard input or standard output.


Peace be unto you. Thank you for visiting!