gpg – encryption and signing tool
gpg [--homedir name] [--options file] [options] command [args]
gpg is the main program for the GnuPG system.
This man page does only list the commands and options available. For a more verbose documentation get the GNU Privacy Handbook (GPH), which is available at http://www.gnupg.org/gph/ . You will find a list of HOWTO documents at http://www.gnupg.org/docs.html .
gpg recognizes these commands:
file (or stdin if no file is
specified) and write it to stdout (or the file specified with
–output). If the decrypted file is signed, the signature is also
verified. This command differs from the default operation, as it
never writes to the filename which is included in the file and it
rejects files which don't begin with an encrypted message.
sigfile is a
signature and verify it without generating any output. With no
arguments, the signature packet is read from stdin (it may be a
detached signature when not used in batch mode). If only a sigfile is
given, it may be a complete signature or a detached signature, in
which case the signed stuff is expected in a file without the ".sig"
or ".asc" extension (if such a file does not exist it is expected at
stdin; use a single dash ("-") as filename to force a read from
stdin). With more than 1 argument, the first should be a detached
signature and the remaining files are the signed stuff.
There is an experimental feature which allows to create keys in batch
mode. See the file doc/DETAILS in the source distribution on how to
use this.
name name If the key is not
yet signed by the default user (or the users given with -u), the
program displays the information of the key again, together with
its fingerprint and asks whether it should be signed. This
question is repeated for all users specified with -u.
n n. Use 0 to
deselect all.
n n. Use 0 to
deselect all.
The listing shows you the key with its secondary keys and all user ids. Selected keys or user ids are indicated by an asterisk. The trust value is displayed with the primary key: the first is the assigned owner trust and the second is the calculated trust value. Letters are used for the values:
name name long key ID name name There are a few other options which control how this command works. Most notable here is the –merge-only options which does not insert new keys but does only the merging of new signatures, user-IDs and subkeys.
key IDs files (or stdin if not given); existing
values will be overwritten.
algo [=files=] 0|1|2 [=count=] mode bits [=qbits=] Long options can be put in an options file (default "~/.gnupg/options"). Do not write the 2 dashes, but simply the name of the option and any required arguments. Lines with a hash as the first non-white-space character are ignored. Commands may be put in this file too, but that does not make sense.
gpg recognizes these options:
file file.
name name as the user ID to sign. This
option is silently ignored for the list commands, so that it can be
used in an options file.
name name as default user ID for signatures.
If this is not used the default user ID is the first user ID found in
the secret keyring.
name, name. If this
option is not specified, GnuPG asks for the user-id unless
–default-recipient is given
name name as default recipient if
option –recipient is not used and don't ask if this is a valid one.
name must be a non empty.
name n n. A value of 0 for n disables
compression. Default is to use the default compression level of zlib
(normally 6).
name name to lookup keys which are not yet in
your keyring. This is only done while verifying messages with
signatures. The option is also required for the command –send-keys
to specify the keyserver to where the keys should be send. All
keyservers synchronize with each other - so there is no need to send
keys to more than one server. Using the command "host -l pgp.net |
grep wwwkeys" gives you a list of keyservers. Because there is load
balancing using round-robin DNS you may notice that you get different
key servers.
file file to the list of keyrings. If file
begins with a tilde and a slash, these are replaced by the HOME
directory. If the filename does not contain a slash, it is assumed to
be in the home-directory ("~/.gnupg" if –homedir is not used). The
filename may be prefixed with a scheme:
"gnupg-ring:" is the default one.
"gnupg-gdbm:" may be used for a GDBM ring. Note that GDBM is experimental and likely to be removed in future versions.
It might make sense to use it together with –no-default-keyring.
file directory directory If this option is not used it defaults to "~/.gnupg". It
does not make sense to use this in a options file. This also
overrides the environment variable "GNUPGHOME".
name name are:
file file and do not try to read
them from the default options file in the homedir (see –homedir).
This option is ignored if used in an options file.
name name does
not contain a slash it is searched in "/usr/local/lib/gnupg" See the
manual for more information about extensions.
flags flags may be given in C syntax (e.g. 0x0042).
n n. See the file DETAILS in the documentation for a
listing of them.
n n and not to
stderr.
string string as comment string in clear text
signatures. To suppress those comment strings entirely, use an empty
string here.
name=value name must consists only of alphanumeric
characters, digits or the underscore; the first character must not be
a digit. value may be any printable string; it will encoded in
UTF8, so sou should have check that your –charset is set right. If
you prefix name with an exclamation mark, the notation data will be
flagged as critical (rfc2440:5.2.3.15).
string string as Policy URL for
signatures (rfc2440:5.2.3.19). If you prefix it with an exclamation
mark, the policy URL packet will be flagged as critical.
string string as the name of file which is
stored in messages.
n n n name name as cipher algorithm. Running the
program with the command –version yields a list of supported
algorithms. If this is not used the cipher algorithm is selected from
the preferences stored with the key.
name name as message digest algorithm.
Running the program with the command –version yields a list of
supported algorithms. Please note that using this option may violate
the OpenPGP requirement, that a 160 bit hash is to be used for DSA.
name name as the cipher algorithm used
to protect secret keys. The default cipher is BLOWFISH. This cipher
is also used for conventional encryption if –cipher-algo is not
given.
name name as the digest algorithm used
to mangle the passphrases. The default algorithm is RIPE-MD-160. This
digest algorithm is also used for conventional encryption if
–digest-algo is not given.
n n is 0 a
plain passphrase (which is not recommended) will be used, a 1
(default) adds a salt to the passphrase and a 3 iterates the whole
process a couple of times. Unless –rfc1991 is used, this mode is
also used for conventional encryption.
n n. Default is 2 which
is RFC1950 compression. You may use 1 to use the old zlib version
(RFC1951) which is used by PGP. The default algorithm may give better
results because the window size is not limited to 8K. If this is not
used the OpenPGP behavior is used, i.e. the compression algorithm is
selected from the preferences; note, that this can't be done if you
do not encrypt the data.
name name as
cipher algorithm. The given name will not be checked so that a later
loaded algorithm will still get disabled.
name name as
public key algorithm. The given name will not be checked so that a
later loaded algorithm will still get disabled.
n n.
If you use 0 for n, the passphrase will be read from stdin. This
can only be used if only one passphrase is supplied. Don't use this
option if you can avoid it.
n We think that Key-Escrow is a Bad Thing; however the user should have the freedom to decide whether to go to prison or to reveal the content of one specific message without compromising all messages ever encrypted for one secret key. DON'T USE IT UNLESS YOU ARE REALLY FORCED TO DO SO.
string string. The format of this string is the same as the
one printed by –show-session-key. This option is normally not used
but comes handy in case someone forces you to reveal the content of
an encrypted message; using this option you can do this without
handing out the secret key.
There are different ways on how to specify a user ID to GnuPG; here are some examples:
The program returns 0 if everything was fine, 1 if at least a signature was bad, and other error codes for fatal errors.
Bob file file file user_ID user_ID pgpfile, gpg –verify sigfile [=files=] sigfile is the detached
signature (either ASCII armored of binary) and [=files=] are the
signed data; if this is not given the name of the file holding the
signed data is constructed by cutting off the extension (".asc" or
".sig") of sigfile or by asking the user for the filename.
Use a good password for your user account and a good passphrase to protect your secret key. This passphrase is the weakest part of the whole system. Programs to do dictionary attacks on your secret keyring are very easy to write and so you should protect your "~/.gnupg/" directory very well.
Keep in mind that, if this program is used over a network (telnet), it is very easy to spy out your passphrase!
On many systems this program should be installed as setuid(root). This is necessary to lock memory pages. Locking memory pages prevents the operating system from writing memory pages to disk. If you get no warning message about insecure memory 3our operating system supports locking without being root. The program drops root privileges as soon as locked memory is allocated.