Transfer Multiple Files One-by-One using CPIO Archives

This variation uses CPIO and level 1 GZIP to compress the data.

Command

On the machine to send the files from assuming that the current directory is /mnt/data, issue:

find . -type f | \
    cpio -o | \
    gzip -1 | \
    openssl enc -aes128 -k "password" \
    nc SERVER.TLD 10000

where:

  • . instructs find to send files, via -type f from the current directory recursively,
  • the files are bundled up in a CPIO archive on the fly via cpio -o,
  • gzip -1 uses one level up gzip compression, meaning just the most basic algorithms to compress the archive,
  • openssl ensures that the compressed archive is encrypted using 128 bit AES and an unsalted key password,
  • netcat nc connects to SERVER.TLD on port 10000 where the files should end up

Conversely, on the machine receiving the files, issue:

nc -l -p <port> | \
    openssl enc -d -aes128 -k "password"
    gunzip | \
    cpio -v -i -d

where:

  • openssl decrypts the stream using 128 bit AES,
  • uses gunzip to decompress the decrypted stream and
  • cpio is used to extract the rezulting archive, where:
    • -v means to be verbose,
    • -i means to extract,
    • -d means to create directories

Remarks

The cpio command sometimes uses the -m flag on the receiving end which instructs cpio to preserve the original modification time of the file. This might be important depending on what the files will be used for because some software is sensitive to the modification time of its files. Otherwise, adding -m is just a waste of time and CPU cycles.


sh/quickly_transfer_files_between_machines/transfer_multiple_files_one-by-one_using_cpio_archives.txt ยท Last modified: 2025/07/12 22:00 by office

Wizardry and Steamworks

© 2025 Wizardry and Steamworks

Access website using Tor Access website using i2p Wizardry and Steamworks PGP Key


For the contact, copyright, license, warranty and privacy terms for the usage of this website please see the contact, license, privacy, copyright.