Old Man Page
- Generate Gpg Key And Pgp Public Key Command Line Code
- Generate Gpg Key And Pgp Public Key Command Lines
- Generate Gpg Key And Pgp Public Key Command Line Download
- Generate Gpg Key And Pgp Public Key Command Line System
- What Is A Pgp Public Key
- Pgp Public Key Server
This is a very old version of the gpg man page. Please see the latestrelease or software package for your operating system to find an up todate version ('man gpg2').
gpg
Export/Publish your public OpenPGP Key. Press Alt+F2 and run gnome-terminal; Create an ASCII armored version of your public key for exporting by typing: gpg -export -a mykey.asc; You’ve just exported your ASCII armored OpenPGP public key to the file mykey.asc in the folder you were in (your home directory, if you opened a. This is a message informing you that the key could not be verified through the web of trust. If you specify at least long key IDs or even better the full fingerprint, you already selected a specific key and can safely omit the trust verification with -trust-model always (but don't do this generally for all operations, consider twice before doing so).
Name
Synopsis
DESCRIPTION
gpg is the main program for the GnuPG system.
This man page does only list the commands and options available. For amore verbose documentation get the GNU Privacy Handbook (GPH), which isavailable at https://www.gnupg.org/gph/ . You will find a list of HOWTOdocuments at https://www.gnupg.org/docs.html .
COMMANDS
gpg recognizes these commands:
Make a signature. This command may be combined with--encrypt.
Make a clear text signature.
Make a detached signature.
Encrypt data. This option may be combined with--sign.
Encrypt with symmetric cipher only This commandasks for a passphrase.
Generate ssh key windows. Store only (make a simple RFC1991 packet).
file
]Decrypt
file
(or stdin if no file isspecified) and write it to stdout (or the file specified with--output). If the decrypted file is signed, the signature is alsoverified. This command differs from the default operation, as itnever writes to the filename which is included in the file and itrejects files which don't begin with an encrypted message.sigfile
] [ signed-files
]]Assume that
sigfile
is asignature and verify it without generating any output. With noarguments, the signature packet is read from stdin (it may be adetached signature when not used in batch mode). If only a sigfile isgiven, it may be a complete signature or a detached signature, inwhich 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 atstdin; use a single dash ('-') as filename to force a read fromstdin). With more than 1 argument, the first should be a detachedsignature and the remaining files are the signed stuff.files
]This is a special version of the --verifycommand which does not work with detached signatures. The commandexpects the files to bee verified either on the commandline or readsthe filenames from stdin; each anem muts be on separate line. Thecommand is intended for quick checking of many files.
names
], --list-public-keys [ names
]List all keysfrom the public keyrings, or just the ones given on the command line.
names
]List all keys from the secretkeyrings, or just the ones given on the command line.
names
]Same as --list-keys, but the signatures arelisted too.
names
]Same as --list-sigs, but the signatures areverified.
names
]List all keys with their fingerprints.This is the same output as --list-keys but with the additional outputof a line with the fingerprint. May also be combined with --list-sigsor --check-sigs. If this command is given twice, the fingerprints ofall secondary keys are listed too.
List only the sequence of packets. This is mainlyuseful for debugging.
Generate a new key pair. This command is normally onlyused interactive.
There is an experimental feature which allows to create keys in batchmode. See the file
doc/DETAILS
in the source distribution on how touse this.name
Present a menu which enables you to do all keyrelated tasks:
- sign
- Make a signature on key of user
name
If the key is notyet signed by the default user (or the users given with -u), theprogram displays the information of the key again, together withits fingerprint and asks whether it should be signed. Thisquestion is repeated for all users specified with -u. - lsign
- Same as --sign but the signature is marked asnon-exportable and will therefore never be used by others. Thismay be used to make keys valid only in the local environment.
- revsig
- Revoke a signature. GnuPG asks for every signature whichhas been done by one of the secret keys, whether a revocationcertificate should be generated.
- trust
- Change the owner trust value. This updates the trust-dbimmediately and no save is required.
- disable, enable
- Disable or enable an entire key. A disabled keycan normally not be used for encryption.
- adduid
- Create an alternate user id.
- deluid
- Delete an user id.
- addkey
- Add a subkey to this key.
- delkey
- Remove a subkey.
- revkey
- Revoke a subkey.
- expire
- Change the key expiration time. If a key is selected,the time of this key will be changed. With no selection the keyexpiration of the primary key is changed.
- passwd
- Change the passphrase of the secret key.
- uid
n
- Toggle selection of user id with index
n
. Use 0 todeselect all. - key
n
- Toggle selection of subkey with index
n
. Use 0 todeselect all. - check
- Check all selected user ids.
- pref
- List preferences.
- toggle
- Toggle between public and secret key listing.
- save
- Save all changes to the key rings and quit.
- quit
- Quit the program without updating the key rings.
The listing shows you the key with its secondary keys and all userids. Selected keys or user ids are indicated by an asterisk. Thetrust value is displayed with the primary key: the first is theassigned owner trust and the second is the calculated trust value.Letters are used for the values:
- -
- No ownertrust assigned / not yet calculated.
- e
- Trust calculation has failed.
- q
- Not enough information for calculation.
- n
- Never trust this key.
- m
- Marginally trusted.
- f
- Fully trusted.
- u
- Ultimately trusted.
name
Sign a public key with you secret key. This is ashortcut version of the subcommand 'sign' from --edit.
name
Sign a public key with you secret key but markit as non-exportable. This is a shortcut version of the subcommand'lsign' from --edit.
long key ID
Assume that the specified key (whichmust be given as a full 8 byte key ID) is as trustworthy as one ofyour own secret keys. This option is useful if you don't want to keepyour secret keys (or one of them) online but still be able to checkthe validity of a given recipient's or signator's key.
name
Remove key from the public keyring
name
Remove key from the secret and publickeyring
Generate a revocation certificate for the completekey. To revoke a subkey or a signature, use the --edit command.
names
]Either export all keys from all keyrings(default keyrings and those registered via option --keyring), or ifat least one name is given, those of the given name. The new keyringis written to stdout or to the file given with option 'output'. Usetogether with --armor to mail those keys.
names
]Same as --export but sends the keys to akeyserver. Option --keyserver must be used to give the name of thiskeyserver. Don't send your complete keyring to a keyserver - selectonly those keys which are new or changed by you.
names
]Same as --export, but does also export keyswhich are not compatible to OpenPGP.
--export-secret-keys [
names
], --export-secret-subkeys[ names
] :: Same as --export, but does export the secret keys. Thisis normally not very useful and a security risk. the second form ofthe command has the special property to render the secret part of theprimary key useless; this is a GNU extension to OpenPGP and otherimplementations can not be expected to successful import such a key.files
], --fast-import [ files
]Import/merge keys.This adds the given keys to the keyring. The fast version does notbuild the trustdb; this can be done at any time with the command--update-trustdb.
There are a few other options which control how this command works.Most notable here is the --merge-only options which does not insertnew keys but does only the merging of new signatures, user-IDs andsubkeys.
key IDs
Import the keys with the given key IDs froma HKP keyserver. Option --keyserver must be used to give the name ofthis keyserver.
List the assigned ownertrust values in ASCIIformat for backup purposes
files
]Update the trustdb with theownertrust values stored in
files
(or stdin if not given); existingvalues will be overwritten.algo
[ files
]Print message digest of algorithm ALGOfor all given files of stdin. If '*' is used for the algorithm,digests for all available algorithms are printed.
0|1|2
[ count
]Emit COUNT random bytes of thegiven quality level. If count is not given or zero, an endlesssequence of random bytes will be emitted. PLEASE, don't use thiscommand unless you know what you are doing, it may remove preciousentropy from the system!
mode
bits
[ qbits
]Use the source, Luke :-). Theoutput format is still subject to change.
Print version information along with a list of supportedalgorithms.
Print warranty information.
Print usage information. This is a really long listeven it does list not all options.
OPTIONS
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 anyrequired arguments. Lines with a hash as the first non-white-spacecharacter are ignored. Commands may be put in this file too, but thatdoes not make sense.
gpg recognizes these options:
Create ASCII armored output.
file
Write output to
file
.name
Use
name
as the user ID to sign. Thisoption is silently ignored for the list commands, so that it can beused in an options file.name
Use
name
as default user ID for signatures.If this is not used the default user ID is the first user ID found inthe secret keyring.name
, Encrypt for user id
name
. If thisoption is not specified, GnuPG asks for the user-id unless--default-recipient is givenname
Use
name
as default recipient ifoption --recipient is not used and don't ask if this is a valid one.name
must be a non empty.Use the default key as default recipientif option --recipient is not used and don't ask if this is a validone. The default key is the first one from the secret keyring or theone set with --default-key.
Reset --default-recipient and--default-recipient-self.
name
Same as --recipient but this one is intendedfor in the options file and may be used together with an own user-idas an 'encrypt-to-self'. These keys are only used when there areother recipients given either by use of --recipient or by the askeduser id. No trust checking is performed for these user ids and evendisabled keys can be used.
Disable the use of all --encrypt-to keys.
Give more information during processing. If usedtwice, the input data is listed in detail.
Try to be as quiet as possible.
n
Set compression level to
n
. A value of 0 for n
disablescompression. Default is to use the default compression level of zlib(normally 6).Use canonical text mode. If -t (but not --textmode)is used together with armoring and signing, this enables clearsignedmessages. This kludge is needed for PGP compatibility; normally youwould use --sign or --clearsign to selected the type of thesignature.
Don't make any changes (this is not completelyimplemented).
Prompt before overwriting any files.
Use batch mode. Never ask, do not allow interactivecommands.
Make sure that the TTY (terminal) is never used for anyoutput. This option is needed in some cases because GnuPG sometimesprints warnings to the TTY if if --batch is used.
Disable batch mode. This may be of use if --batch isenabled from an options file.
Assume 'yes' on most questions.
Assume 'no' on most questions.
Skip key validation and assume that used keys arealways fully trusted. You won't use this unless you have installedsome external validation scheme.
name
Use
name
to lookup keys which are not yet inyour keyring. This is only done while verifying messages withsignatures. The option is also required for the command --send-keysto specify the keyserver to where the keys should be send. Allkeyservers synchronize with each other - so there is no need to sendkeys to more than one server. Using the command 'host -l pgp.net |grep wwwkeys' gives you a list of keyservers. Because there is loadbalancing using round-robin DNS you may notice that you get differentkey servers.This option disables the automaticretrieving of keys from a keyserver while verifying signatures. Thisoption allows to keep a keyserver in the options file or the--send-keys and --recv-keys commands.
Try to access the keyserver over the proxy setwith the variable 'httpproxy'.
file
Add
file
to the list of keyrings. If file
begins with a tilde and a slash, these are replaced by the HOMEdirectory. If the filename does not contain a slash, it is assumed tobe in the home-directory ('~/.gnupg' if --homedir is not used). Thefilename may be prefixed with a scheme:'gnupg-ring:' is the default one.
'gnupg-gdbm:' may be used for a GDBM ring. Note that GDBM isexperimental and likely to be removed in future versions.
It might make sense to use it together with --no-default-keyring.
file
Same as --keyring but for the secretkeyrings.
directory
Set the name of the home directory to
directory
If this option is not used it defaults to '~/.gnupg'. Itdoes not make sense to use this in a options file. This alsooverrides the environment variable 'GNUPGHOME'.name
Set the name of the native character set. This isused to convert some strings to proper UTF-8 encoding. Valid valuesfor
name
are:- iso-8859-1
- This is the default Latin 1 set.
- iso-8859-2
- The Latin 2 set.
- koi8-r
- The usual Russian set (rfc1489).
Assume that the arguments arealready given as UTF8 strings. The default (--no-utf8-strings) is toassume that arguments are encoded in the character set as specifiedby --charset. These options effects all following arguments. Bothoptions may used multiple times.
file
Read options from
file
and do not try to readthem from the default options file in the homedir (see --homedir).This option is ignored if used in an options file.Shortcut for '--options /dev/null'. This option isdetected before an attempt to open an option file.
name
Load an extension module. If
name
doesnot contain a slash it is searched in '/usr/local/lib/gnupg' See themanual for more information about extensions.flags
Set debugging flags. All flags are or-ed and
flags
may be given in C syntax (e.g. 0x0042).Set all useful debugging flags.
n
Write special status strings to the filedescriptor
n
. See the file DETAILS in the documentation for alisting of them.n
Write log output to file descriptor
n
and not tostderr.Do not write comment packets. This option affectsonly the generation of secret keys. Please note, that this hasnothing to do with the comments in clear text signatures.
string
Use
string
as comment string in clear textsignatures. To suppress those comment strings entirely, use an emptystring here.Force to write the standard comment string inclear text signatures. Call of duty 2 cd key generator 2020 pc ps4 xbox. Use this to overwrite a --comment from aconfig file.
Omit the version string in clear text signatures.
Force to write the version string in clear textsignatures. Use this to overwrite a previous --no-version from aconfig file.
name=value
Put the name value pair into thesignature as notation data.
name
must consists only of alphanumericcharacters, digits or the underscore; the first character must not bea digit. value
may be any printable string; it will encoded inUTF8, so sou should have check that your --charset is set right. Ifyou prefix name
with an exclamation mark, the notation data will beflagged as critical (rfc2440:5.2.3.15).string
Use
string
as Policy URL forsignatures (rfc2440:5.2.3.19). If you prefix it with an exclamationmark, the policy URL packet will be flagged as critical.string
Use
string
as the name of file which isstored in messages.Try to create a file with a name asembedded in the data. This can be a dangerous option as it allows tooverwrite files.
n
Number of completely trusted users tointroduce a new key signer (defaults to 1).
n
Number of marginally trusted users tointroduce a new key signer (defaults to 3)
n
Maximum depth of a certification chain(default is 5).
name
Use
name
as cipher algorithm. Running theprogram with the command --version yields a list of supportedalgorithms. If this is not used the cipher algorithm is selected fromthe preferences stored with the key.name
Use
name
as message digest algorithm.Running the program with the command --version yields a list ofsupported algorithms. Please note that using this option may violatethe OpenPGP requirement, that a 160 bit hash is to be used for DSA.name
Use
name
as the cipher algorithm usedto protect secret keys. The default cipher is BLOWFISH. This cipheris also used for conventional encryption if --cipher-algo is notgiven.name
Use
name
as the digest algorithm usedto mangle the passphrases. The default algorithm is RIPE-MD-160. Marvel heroes generator tool license key online. Thisdigest algorithm is also used for conventional encryption if--digest-algo is not given.n
Selects how passphrases are mangled. If
n
is 0 aplain passphrase (which is not recommended) will be used, a 1(default) adds a salt to the passphrase and a 3 iterates the wholeprocess a couple of times. Unless --rfc1991 is used, this mode isalso used for conventional encryption.n
Use compress algorithm
n
. Default is 2 whichis RFC1950 compression. You may use 1 to use the old zlib version(RFC1951) which is used by PGP. The default algorithm may give betterresults because the window size is not limited to 8K. If this is notused the OpenPGP behavior is used, i.e. the compression algorithm isselected from the preferences; note, that this can't be done if youdo not encrypt the data.name
Never allow the use of
name
ascipher algorithm. The given name will not be checked so that a laterloaded algorithm will still get disabled.Generate Gpg Key And Pgp Public Key Command Line Code
name
Never allow the use of
name
aspublic key algorithm. The given name will not be checked so that alater loaded algorithm will still get disabled.Do not put the keyid into encrypted packets. Thisoption hides the receiver of the message and is a countermeasureagainst traffic analysis. It may slow down the decryption processbecause all available secret keys are tried.
This option changes the behavior of cleartextsignatures so that they can be used for patch files. You should notsend such an armored file via email because all spaces and lineendings are hashed too. You can not use this option for data whichhas 5 dashes at the beginning of a line, patch files don't have this.A special armor header line tells GnuPG about this cleartextsignature option.
Because some mailers change lines startingwith 'From ' to '<From ' it is good to handle such lines in a specialway when creating cleartext signatures. All other PGP versions do itthis way too. This option is not enabled by default because it wouldviolate rfc2440.
n
Read the passphrase from file descriptor
n
.If you use 0 for n
, the passphrase will be read from stdin. Thiscan only be used if only one passphrase is supplied. Don't use thisoption if you can avoid it.n
This is a replacement for the depreciatedshared-memory IPC mode. If this option is enabled, user input onquestions is not expected from the TTY but from the given filedescriptor. It should be used together with --status-fd. See the filedoc/DETAILS in the source distribution for details on how to use it.
Try to be more RFC1991 (PGP 2.x) compliant.
Reset all packet, cipher and digest options to OpenPGPbehavior. Use this option to reset all previous options like--rfc1991, --force-v3-sigs, --s2k-*, --cipher-algo, --digest-algo and--compress-algo to OpenPGP compliant values. All PGP workarounds arealso disabled.
OpenPGP states that an implementation shouldgenerate v4 signatures but PGP 5.x recognizes v4 signatures only onkey material. This options forces v3 signatures for signatures ondata.
Force the use of encryption with appended manipulationcode. This is always used with the newer cipher (those with ablocksize greater than 64 bit). This option might not be implementedyet.
Allow the import of keys with user IDswhich are not self-signed. This is only allows the import - keyvalidation will fail and you have to check the validity of the key myother means. This hack is needed for some German keys generated withpgp 2.6.3in. You should really avoid using it, because OpenPGP hasbetter mechanics to do separate signing and encryption keys.
Disable all checks on the form of the user IDwhile generating a new one. This option should only be used in veryspecial environments as it does not ensure the de-facto standardformat of user IDs.
GnuPG normally checks that the timestampsassociated with keys and signatures have plausible values. However,sometimes a signature seems to be older than the key due to clockproblems. This option makes these checks just a warning.
Lock the databases the first time a lock is requestedand do not release the lock until the process terminates.
Release the locks every time a lock is no longerneeded. Use this to override a previous --lock-once from a configfile.
Disable locking entirely. This option should be usedonly in very special environments, where it can be assured that onlyone process is accessing those files. A bootable floppy with astandalone encryption system will probably use this. Improper usageof this option may lead to data and key corruption.
GnuPG uses a file to store it's internalrandom pool over invocations. This makes random generation faster;however sometimes write operations are not desired. This option canbe used to achive that with the cost of slower random generation.
Reset verbose level to 0.
Suppress the initial copyright message but do notenter batch mode.
Suppress the warning about 'using insecurememory'.
Assume the input data is not in ASCII armored format.
Do not add the default keyrings to the listof keyrings.
Skip the signature verification step. This may beused to make the decryption faster if the signature verification isnot needed.
Generate Gpg Key And Pgp Public Key Command Lines
Print key listings delimited by colons.
Print key listings delimited by colons and printthe public key data.
Same as the command --fingerprint but changesonly the format of the output and may be used together with anothercommand.
Changes the output of the list commands to workfaster; this is achieved by leaving some parts empty. Someapplications don't need the user ID and the trust information givenin the listings. By using this options they can get a faster listing.The excact behaviour of this option may change in future versions.
Changes the behaviour of some commands. This is like--dry-run but different in some cases. The semantic of this commandmay be extended in the future. Currently it does only skip the actualdecryption pass and therefore enables a fast listing of theencryption keys.
This is not for normal use. Use the source to see forwhat it might be useful.
This is not for normal use. Use the source to seefor what it might be useful.
GnuPG versions prior to 1.0.2 had a bug inthe way a signature was encode. This options enables a workaround bychecking faulty signatures again with the encoding used in oldversions. This may only happen for ElGamal signatures which are notwidely used.
Display the session key used for one message.See --override-session-key for the counterpart of this option.
We think that Key-Escrow is a Bad Thing; however the user should havethe freedom to decide whether to go to prison or to reveal thecontent of one specific message without compromising all messagesever encrypted for one secret key. DON'T USE IT UNLESS YOU ARE REALLYFORCED TO DO SO.
string
Don't use the public key but thesession key
string
. The format of this string is the same as theone printed by --show-session-key. This option is normally not usedbut comes handy in case someone forces you to reveal the content ofan encrypted message; using this option you can do this withouthanding out the secret key.Don't insert new keys into the keyrings while doingan import.
Don't look at the key ID as stored in themessage but try all secret keys in turn to find the right decryptionkey. This option forces the behaviour as used by anonymous recipients(created by using --throw-keyid) and might come handy in case wherean encrypted message contains a bogus key ID.
How to specify a user ID
There are different ways on how to specify a user ID to GnuPG; here aresome examples:
- :: Used to locate the default home directory.
- Here the key ID isgiven in the usual short form.
- 234AABBCC34567C4, 0F323456784E56EAB, 01AB3FED1347A5612,0x234AABBCC34567C4 :: Here the key ID is given in the long form asused by OpenPGP.
- 1234343434343434C434343434343434,123434343434343C3434343434343734349A3434,0E12343434343434343434EAB3484343434343434,0xE12343434343434343434EAB3484343434343434 :: The best way to specifya key ID is by using the fingerprint of the key. This avoids anyambiguities in case that there are duplicated key IDs (which arereally rare for the long key IDs).
- Using an exact tomatch string. The equal sign indicates this.
- Using the email address part whichmust match exactly. The left angle bracket indicates this emailaddress mode.
- All words must match exactly (not casesensitive) but can appear in any order in the user ID. Words are anysequences of letters, digits, the underscore and all characters withbit 7 set.
- Using the Local ID. This is a very low level method and shouldonly be used by applications which really need it. The hash characterindicates this method. An application should not assume that this isonly a number.
- By case insensitive substring matching. This is thedefault mode but applications may want to explicitely indicate thisby putting the asterisk in front.
RETURN VALUE
The program returns 0 if everything was fine, 1 if at least a signaturewas bad, and other error codes for fatal errors.
EXAMPLES
- gpg -se -r
Bob
file
- sign and encrypt for user Bob
- gpg --clearsign
file
- make a clear text signature
- gpg -sb
file
- make a detached signature
- gpg --list-keys
user_ID
- show keys
- gpg --fingerprint
user_ID
- show fingerprint
- gpg --verify
pgpfile
, gpg --verifysigfile
[files
] - Verifythe signature of the file but do not output the data. The second formis used for detached signatures, where
sigfile
is the detachedsignature (either ASCII armored of binary) and [files
] are thesigned data; if this is not given the name of the file holding thesigned data is constructed by cutting off the extension ('.asc' or'.sig') ofsigfile
or by asking the user for the filename.
ENVIRONMENT
- HOME
- Used to locate the default home directory.
- GNUPGHOME
- If set directory used instead of '~/.gnupg'.
- httpproxy
- Only honored when the option --honor-http-proxy isset.
FILES
- ~/.gnupg/secring.gpg
- The secret keyring
- ~/.gnupg/secring.gpg.lock
- and the lock file
- ~/.gnupg/pubring.gpg
- The public keyring
- ~/.gnupg/pubring.gpg.lock
- and the lock file
- ~/.gnupg/trustdb.gpg
- The trust database
- ~/.gnupg/trustdb.gpg.lock
- and the lock file
- ~/.gnupg/randomseed
- used to preserve the internal random pool
- ~/.gnupg/options
- May contain options
- /usr[/local]/share/gnupg/options.skel
- Skeleton options file
- usr[/local]/lib/gnupg
- Default location for extensions
WARNINGS
Use a good password for your user account and a good passphrase toprotect your secret key. This passphrase is the weakest part of thewhole system. Programs to do dictionary attacks on your secret keyringare 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), itis very easy to spy out your passphrase!
BUGS
On many systems this program should be installed as setuid(root). Thisis necessary to lock memory pages. Locking memory pages prevents theoperating system from writing memory pages to disk. If you get nowarning message about insecure memory 3our operating system supportslocking without being root. The program drops root privileges as soon aslocked memory is allocated.
I use GPG (also known as GnuPG) software for encrypting files that contain sensitive information (mostly passwords). As a systems engineer, I do most of my work on remote servers, accessible via command line interface. Naturally, I find it easier to use the command line version of GPG to directly encrypt and decrypt documents.
GPG (GNU Privacy Guard) is a free open source version of PGP (Pretty Good Privacy) encryption software. Conceptually, both use the same approach to cryptography (i.e. encryption and decryption). However, each is uniquely different in its implementation.
What follows is a quick primer on how to install the GPG command line tools, as well as a list of basic commands you are most likely to need.
GPG can be installed in a number of different ways. The instructions here will install the core GPG command line tools, which are intended to be used in a terminal.
If, on the other hand, you prefer a graphical user interface (or GUI) for accessing GPG functionality (e.g. encrypting email communications, or encrypting documents in a GUI text editor), refer to the links at the end of this article.
Red Hat / CentOS
Ubuntu / Debian
Mac OS X
The easiest way to install the GPG command line tools on your Mac is to first install Homebrew, a package management system that makes thousands of software packages available for install on your Mac.
Open a Terminal window (Applications > Utilities menu), then enter the following command.
When that’s complete, install the GPG software package with the following command.
What follows is a very brief introduction to command line usage of GPG. Think of it as a “quick reference” or a “cheat sheet.” You should certainly learn more about GPG than what is explained within this post. It is intended only to get you started. If you expect to use GPG more extensively, I strongly advise you to read more documentation (see the Links section below).
GPG is powerful encryption software, but it can also be easy to learn — once you understand some basics. GPG uses a method of encryption known as public key cryptography, which provides a number of advantages and benefits. However, to obtain these advantages, a minimal level of complexity is required to make it all work. For an overview of how public key cryptography works, read the Introduction to Cryptography (link at the bottom of this post).
Typographical conventions used in commands:
In all examples below, text that you will need to replace with your own values (e.g. usernames, email addresses, filenames) is shown in “gray italic”. Text that you will type literally (unchanged) is indicated with “black constant width”.
Create your GPG key:
To get started with GPG, you first need to generate your key pair. That is, you will generate both a private and a public key with a single command. Enter your name and email address at the prompts, but accept the default options otherwise.
The first key is your private (or secret) key. You must keep this private key safe at all times, and you must not share it with anyone. The private key is protected with a password. Try to make the password as long as possible, but something you will not forget. If you forget the password, there’s no way to recover it. For the same reason, you should also make a backup copy of your private key. (Consider using Time Machine for backups on Mac OS X.)
The second key is your public key, which you can safely share with other people.
The relationship of the private and public key is actually very simple. Anything that is encrypted using the public key can only be decrypted with the related private key. Therefore, you will provide your public key to another person, and they will provide you with their public key. Anything encrypted to your public key can only be decrypted by you. Anything encrypted to the other person’s public key can only be decrypted by the other person.
Export your public key:
The next step is to export your public key and share it with another person. That person should do the same, and export their public key.
Import another person’s public key:
When you import a public key, you are placing it into what is commonly referred to as your GPG “keyring.”
List the public keys in your keyring:
You can now view a list of public keys in your keyring, as well as the name and email address associated with each key.
List private keys in your keyring:
Crysis 2 serial key generator download. The following command will list the private keys in your keyring. This will show your own private key, which you created earlier.
Trust a public key:
Once you have imported the other person’s public key, you must now set the trust level of the key. This prevents GPG from warning you every time you encrypt something with that public key.
Specify the other person’s name or email in the command.
GPG has many options, most of which you will never need. Here’s a quick list of the most useful commands you are likely to need.
Encrypt a file:
To encrypt a file named filename.txt for a single individual, specify that individual as a recipient.
This will create a new encrypted file named filename.txt.gpg.
If you want to encrypt a file so that only you yourself can decrypt it, then specify yourself as the recipient.
If you want to encrypt a file so that both you and another person can decrypt the file, specify both you and the other person as recipients.
If you want to encrypt a file for a group of people, define the group in your gpg.conf file (see section below), and then specify the group as a recipient.
After a while, you’ll want to be more concise and use the short version of the command line options. Here’s the same command.
Decrypt a file to terminal (standard output):
The first version of this command will display the content of a file within the terminal window itself.
Use the
--decrypt
option only if the file is an ASCII text file. If it’s a binary file, then omit the --decrypt
option, which will write the decrypted file to disk. At that point, you can open the binary file in whatever application is used to view the file.Generate Gpg Key And Pgp Public Key Command Line Download
Decrypt a file to disk:
Whether the file is ASCII or binary, if you want to make changes to the content of an encrypted file, you must first decrypt it, make your changes, then re-encrypt the file. As I mentioned in the previous paragraph, you write the decrypted version of a file to disk, by omitting the
--decrypt
option from the command.If the encrypted file was named filename.txt.gpg, the above command will create a decrypted version named filename.txt (with the .gpg extension removed).
Create Groups of People in Your GPG Configuration File
For convenience, you can pre-define a group of people in your GPG configuration file. This has the benefit of allowing you to encrypt a file to every member of the group by specifying only the group name as the recipient, rather than tediously specifying every individual member of the group.
Your GPG software configuration is stored in your home directory within the
~/.gnupg/gpg.conf
file. Edit this file using your favorite command line text editor (vim, nano, pico, emacs, etc). While there are numerous settings available in the configuration file, go to the section pertinent to defining groups.When defining a group, you list the members of the group. Each member is referenced by some attribute of their public key found in your GPG keyring — typically a person’s name (or partial name, such as first or last name) or an email address (or partial email address).
Generate Gpg Key And Pgp Public Key Command Line System
If you are a member of the group, remember to include yourself in the group! If you do not list yourself in the group, you won’t be able to decrypt any files you encrypt to the group.
Here’s an example of a group named “journalists”, listing the first name of each person.
I encourage you to learn more about GPG. See the Links below.
You may also want to learn about secure methods to erase files from your computer hard drive. Mac OS X has the “Secure Empty Trash” option within Finder. There are also numerous third-party tools you can install.
Since we’re on the theme of learning how to use GPG in the command line, you may want to try “bcwipe” — a program to securely erase files within the command line.
What Is A Pgp Public Key
On Mac OS X, you can install bcwipe via Homebrew.
General
Pgp Public Key Server
- Introduction to Cryptography (PDF)
- Homebrew (Package Manager for Mac OS X)
GUI Tools
- GPG Suite (GUI for Mac OS X)
- How To Use GPG Suite on Mac OS X (Electronic Frontier Foundation)
- Gpg4win (GUI for Windows)
- How To Use Gpg4Win on Windows (Electronic Frontier Foundation)