search
[last updated: 2023-07-11]
GnuPG encryption home page
-----
This page is just an unorganized collection of notes ...
gpg -a --export "David Steele" | gpg --list-packets --verbose
where “David Steele” matches a UID for my key. Substitute your name, email, or primary key id to see your key certificate. Add the ‘--debug 0x02’ option to the second gpg invocation to see the entire contents, including the binary key data (thanks superuser.com).
Note that there are other tools which provide more information or features for this task. I use gpg as the least common denominator tool.
This is a pretty standard published key certificate, which is to say that it contains a primary certification/signing public key, with a public subkey dedicated to encryption (GPG always creates a separate encryption subkey to the primary, to avoid problems). I also have an extra public signing subkey with an expiration date, for a couple of reasons.
----------------------------------------
PUBKEY_USAGE_SIG S key is good for signing
PUBKEY_USAGE_CERT C key is good for certifying other signatures
PUBKEY_USAGE_ENC E key is good for encryption
PUBKEY_USAGE_AUTH A key is good for authentication
other notes:
signing someone's key:
To sign a key that you’ve imported, simply type:
gpg --sign-key email@example.com
When you sign the key, it means you verify that you trust the person is who they claim to be. This can help other people decide whether to trust that person too. If someone trusts you, and they see that you’ve signed this person’s key, they may be more likely to trust their identity too.
You should allow the person whose key you are signing to take advantage of your trusted relationship by sending them back the signed key. You can do this by typing:
gpg --output ~/signed.key --export --armor email@example.com
----------------------------------------
other stuff to review and incorporate...
make your public key publicly available. People can then find your information to send you messages securely from your very first interaction.
You can send anyone your public key by requesting it from the GPG system:
gpg --output ~/mygpg.key --armor --export your_email@address.com
Output
-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.11 (GNU/Linux)
mQINBFJPCuABEACiog/sInjg0O2SqgmG1T8n9FroSTdN74uGsRMHHAOuAmGLsTse
9oxeLQpN+r75Ko39RVE88dRcW710fPY0+fjSXBKhpN+raRMUKJp4AX9BJd00YA/4
EpD+8cDK4DuLlLdn1x0q41VUsznXrnMpQedRmAL9f9bL6pbLTJhaKeorTokTvdn6
5VT3pb2o+jr6NETaUxd99ZG/osPar9tNThVLIIzG1nDabcTFbMB+w7wOJuhXyTLQ
JBU9xmavTM71PfV6Pkh4j1pfWImXc1D8dS+jcvKeXInBfm2XZsfOCesk12YnK3Nc
u1Xe1lxzSt7Cegum4S/YuxmYoh462oGZ7FA4Cr2lvAPVpO9zmgQ8JITXiqYg2wB3
. . .
You can then send this file to the other party over an appropriate medium.
If you want to publish your key to a key server, you can do it manually through the forms available on most of the server sites.
Another option is to do this through the GPG interface. Look up your key ID by typing:
gpg --list-keys your_email@address.com
The highlighted portion in the output below is the key ID (look for the pub along the left-hand column if you’re uncertain about which one to use). It is a short way to reference the key to the internal software.
Output
pub 4096R/311B1F84 2013-10-04
uid Test User
sub 4096R/8822A56A 2013-10-04
To upload your key to a certain key server, you can then use this syntax:
gpg --send-keys --keyserver pgp.mit.edu key_id
The key will be uploaded to the specified server. Afterwards, it will likely be distributed to other key servers around the world.
----------------------------------------
----------------------------------------
gpg --list-secret-keys --keyid-format=long
----------------------------------------------
I think this allows you to update your key, the email associated with it, etc.:
Note: Some GPG installations on Linux may require you to use gpg2 --list-keys --keyid-format LONG to view a list of your existing keys instead. In this case you will also need to configure Git to use gpg2 by running git config --global gpg.program gpg2.
From the list of GPG keys, copy the long form of the GPG key ID you'd like to use. In this example, the GPG key ID is 3AA5C34371567BD2:
Shell
$ gpg --list-secret-keys --keyid-format=long
/Users/hubot/.gnupg/secring.gpg
------------------------------------
sec 4096R/3AA5C34371567BD2 2016-03-10 [expires: 2017-03-10]
uid Hubot
ssb 4096R/4BB6D45482678BE3 2016-03-10
Enter gpg --edit-key GPG key ID, substituting in the GPG key ID you'd like to use. In the following example, the GPG key ID is 3AA5C34371567BD2:
gpg --edit-key 3AA5C34371567BD2
Enter gpg> adduid to add the user ID details.
gpg> adduid
Follow the prompts to supply your real name, email address, and any comments. You can modify your entries by choosing N, C, or E. To keep your email address private, use your GitHub-provided no-reply email address. For more information, see "Setting your commit email address."
Real Name: OCTOCAT
Email address: "octocat@github.com"
Comment: GITHUB-KEY
Change (N)ame, (C)omment, (E)mail or (O)kay/(Q)uit?
Enter O to confirm your selections.
Enter your key's passphrase.
Enter gpg> save to save the changes
gpg> save
Enter gpg --armor --export GPG key ID, substituting in the GPG key ID you'd like to use. In the following example, the GPG key ID is 3AA5C34371567BD2:
$ gpg --armor --export 3AA5C34371567BD2
# Prints the GPG key, in ASCII armor format
----------------------------------------------