LinuxCommandLibrary

gpg-zip

Encrypt and compress files using GPG

TLDR

Encrypt a directory into archive.gpg using a passphrase

$ gpg-zip [[-c|--symmetric]] [[-o|--output]] [archive.gpg] [path/to/directory]
copy

Decrypt archive.gpg into a directory of the same name
$ gpg-zip [[-d|--decrypt]] [path/to/archive.gpg]
copy

List the contents of the encrypted archive.gpg
$ gpg-zip --list-archive [path/to/archive.gpg]
copy

SYNOPSIS

gpg-zip [options] [files...]
gpg-zip -d | --decrypt [options] gpgz-file

PARAMETERS

--encrypt
    Encrypt files

--decrypt, -d
    Decrypt and decompress files

--sign
    Sign files

--symmetric
    Symmetric (passphrase) encryption

--armor, -a
    Produce ASCII-armored output

--recipient, -r
    Encrypt for recipient name

--hidden-recipient, -R
    Hidden recipient name

--local-user, -u
    Local user/key name

--sign-with
    Sign with specific keyid

--compress-algo
    Inner GPG compression algorithm

--compress-level
    Compression level 1-9

--output, -o
    Write output to file

--yes, -y
    Overwrite without prompting

--batch
    Batch mode, no prompts

--verbose, -v
    Verbose output

--quiet, -q
    Suppress output

--homedir


    Use dir for GPG home

DESCRIPTION

gpg-zip is a convenience wrapper script from the GnuPG package that automates compressing files with gzip and encrypting or signing them with gpg in a single step. It produces a .gpgz output file combining compression and cryptographic protection, ideal for secure backups, email attachments, or archiving sensitive data.

The workflow pipes input files through gzip for compression, then gpg for encryption/signing (or reverse for decryption). For encryption, specify recipients with --recipient; use --symmetric for passphrase protection. Signing integrates with --sign or --sign-with. Multiple input files are concatenated before processing.

Decryption uses --decrypt or -d, automatically decompressing output. It passes most gpg options transparently, enhancing flexibility. While efficient for standard use, it's gzip-specific—no other compressors—and assumes GnuPG keys are configured. Widely used for its simplicity over manual piping.

CAVEATS

Always uses gzip externally; multiple files concatenated before processing. Passes unknown options to gpg, but decryption requires matching keys. Not suitable for non-gzip compression needs.

EXAMPLES

gpg-zip --encrypt --recipient alice files.txt → files.txt.gpgz
gpg-zip --symmetric --output secret.gpgz docs/
gpg-zip -d archive.gpgz → extracts decrypted files

DECRYPTION NOTE

Use gpg-zip -d file.gpgz; prompts for passphrase/key if needed, outputs to stdout or --output file.

HISTORY

Introduced in GnuPG 1.0 (circa 2001) as a user-friendly script; maintained in GnuPG 1.4/2.x for backward compatibility, though manual gpg | gzip preferred in modern workflows.

SEE ALSO

gpg(1), gpg2(1), gzip(1), gunzip(1)

Copied to clipboard