Linux command
gpg2 命令
安全
权限或系统影响较大,执行前请核对目标。
常用示例
Generate key pair
gpg2 --full-generate-key
List keys
gpg2 --list-keys
Encrypt file for recipient
gpg2 -e -r [recipient@email.com] [file]
Decrypt file
gpg2 -d [file.gpg]
Sign file
gpg2 --sign [file]
Verify signature
gpg2 --verify [file.sig]
Export public key
gpg2 --armor --export [keyid] > [public.asc]
Import a key
gpg2 --import [public.asc]
Symmetric encryption
gpg2 -c [file]
说明
gpg2 (GnuPG 2) is the modern version of GNU Privacy Guard, implementing the OpenPGP standard for encryption, digital signatures, and key management. It uses a modular architecture with separate daemons for improved security. On most modern systems, gpg is aliased to gpg2. The two share keyrings and are functionally equivalent, with gpg2 offering improved architecture and daemon management.
参数
- -e, --encrypt
- Encrypt data.
- -d, --decrypt
- Decrypt data.
- -s, --sign
- Sign data.
- --verify
- Verify signature.
- -r, --recipient _name_
- Encrypt for recipient.
- -a, --armor
- ASCII armored output.
- --gen-key
- Generate key pair with default settings.
- --full-generate-key
- Generate key pair with full options (algorithm, size, expiry).
- --list-keys
- List public keys.
- --list-secret-keys
- List private keys.
- --export _keyid_
- Export public key.
- --import _file_
- Import keys.
- --delete-keys _keyid_
- Delete public key from keyring.
- --delete-secret-keys _keyid_
- Delete secret key from keyring.
- --keyserver _server_
- Keyserver to use.
- -o, --output _file_
- Write output to file instead of stdout.
- --clearsign
- Make a cleartext signature.
- --detach-sign
- Make a detached signature.
- -c, --symmetric
- Encrypt with a symmetric cipher using a passphrase.
- --batch
- Run in non-interactive batch mode.
- -q, --quiet
- Minimize output.
- -v, --verbose
- Display detailed processing information.
FAQ
What is the gpg2 command used for?
gpg2 (GnuPG 2) is the modern version of GNU Privacy Guard, implementing the OpenPGP standard for encryption, digital signatures, and key management. It uses a modular architecture with separate daemons for improved security. On most modern systems, gpg is aliased to gpg2. The two share keyrings and are functionally equivalent, with gpg2 offering improved architecture and daemon management.
How do I run a basic gpg2 example?
Run `gpg2 --full-generate-key` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -e, --encrypt do in gpg2?
Encrypt data.