gpg - Unix, Linux Command

gpg  [--homedir name]  [--options file]  [options]  command  [args]   


gpg is the main program for the GnuPG system.




This man page only lists the commands and options available.  For more
verbose documentation get the GNU Privacy Handbook (GPH) or one of the
other documents at http://www.gnupg.org/documentation/ .


Please remember that option parsing stops as soon as a non option is
encountered, you can explicitly stop option parsing by using the
special option "--".


gpg may be run with no commands, in which case it will
perform a reasonable action depending on the type of file it is given
as input (an encrypted message is decrypted, a signature is verified,
a file containing keys is listed).


gpg recognizes these commands:


See the option --simple-sk-checksum if you want to import such an
exported key with an older OpenPGP implementation.


Long options can be put in an options file (default
"~/.gnupg/gpg.conf").  Short option names will not work - for example,
"armor" is a valid option for the options file, while "a" is not.  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 is not generally useful as the command will execute
automatically with every execution of gpg.


gpg recognizes these options:






There are different ways 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.




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!


If you are going to verify detached signatures, make sure that the
program knows about it; either give both filenames on the command line
or use - to specify stdin.


GnuPG tries to be a very flexible implementation of the OpenPGP
standard.  In particular, GnuPG implements many of the optional parts
of the standard, such as the SHA-512 hash, and the ZLIB and BZIP2
compression algorithms.  It is important to be aware that not all
OpenPGP programs implement these optional algorithms and that by
forcing their use via the --cipher-algo, --digest-algo,
--cert-digest-algo, or --compress-algo options in GnuPG, it is
possible to create a perfectly valid OpenPGP message, but one that
cannot be read by the intended recipient.


There are dozens of variations of OpenPGP programs available, and each
supports a slightly different subset of these optional algorithms.
For example, until recently, no (unhacked) version of PGP supported
the BLOWFISH cipher algorithm.  A message using BLOWFISH simply could
not be read by a PGP user.  By default, GnuPG uses the standard
OpenPGP preferences system that will always do the right thing and
create messages that are usable by all recipients, regardless of which
OpenPGP program they use.  Only override this safe default if you
really know what you are doing.


If you absolutely must override the safe default, or if the
preferences on a given key are invalid for some reason, you are far
better off using the --pgp6, --pgp7, or --pgp8 options.  These options
are safe as they do not force any particular algorithms in violation
of OpenPGP, but rather reduce the available algorithms to a "PGP-safe"
list.



GPG (GNU Privacy Guard) is a public key cryptography implementation.
It allows for the secure transmission of information and can be used to
verify that the origin of a message is genuine. Below are few examples of usage.
$ gpg --gen-key

$ gpg --gen-revoke myname@mydomain.com

$ gpg --import public_key_file

$ gpg --sign-key yourname@yourdomain.com

$ gpg --export --armor yourname@yourdomain.com

$ gpg --import signed_key_file_name

$ gpg --list-keys

$ gpg --list-secret-keys

$ gpg --refresh-keys

$ gpg --encrypt --recipient MyFriend@frienddomain.com file.txt

$ gpg --encrypt --recipient MyFriend@frienddomain.com --recepient OneMoreFriend@frienddomain.com file.txt

$ gpg --encrypt --recipient MyName@mydomain.com file.txt

$ gpg --decrypt encrypted_file.txt.gpg

$ gpg encrypted_file.gpg