GPG (technically GNU Privacy Guard but no one calls it that; previously PGP or Pretty Good Privacy) is an asymmetric public-private key encryption scheme, used for encryption and also verification (signing of documents).
Acquire the gpg
binary. Most Linux distros have this installed by default, otherwise install it with your package manager or from the website. You may also have gpg2
; that’s the newer version, and it may be what your package manager aliases gpg
to. Both versions have virtually the external interface so it doesn’t really matter. just pacman -Syu gnupg
or apt-get install gpg
or whatever.
gpg --full-gen-key
. This command will ask you some questions; answer them. Here are the suggested settings of the *Arch Wiki*.
gpg --export -a "<User Name email@whatever.com>" | tee public.key
. Export your key so you can share it. This is contacts can encrypt messages to you, so it should be accessible. For example, here’s my key:
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQINBGIvsR4BEADivrT4C+hw2DFzM8mFwDUN/r+aErEhXgYRFRWxd0N8Mz4JNaB1
/Dzg2a3PaoJoFrrDNUDQT3FEXkKoiC52ehqjurbk1WA3tS9Vew7NPzjLRIZ47WX7
PfDIvXIBjIPsMJHBqRN/v0FZJJpkQzyP5wkHI7uSl9MeU6EPJsWXe/MJ/Cq04Te4
jNlf2rJ/djdG36Q1V+QQxkpdYzPi0G3gtVeMJ7nKHC3oBlr3IUb6v6Q6dn4MAfUR
QSfSwYrEDOMVoqwz/b4iQQuvVU1ZtnXGa9W2bTc7OF95UyDdNRRK0h880cI+GJpY
ZE5CO9SULolte/gRJFjFHpdSurWlyShwdlzS8BBatXst0yzHzcTZypcDgzd/vouu
5lbfVkDHPsmxtcEsVJl7gezXH3BUvSOMpcyShwcILtcRJx9R0nCng8jHoxghSA4J
jjh4/TPnBldpMkHlT070EZqIEfRz7xW9sejm+KmR/4St+iKJHkBgusASpnx1SaN4
RK7vukDiGQSSbSjcNh2/Xrz3k7LgO6poVw88dOP70uO7JC64LA9EqGgX9RYm+tpf
DzgW00MRMXOHlYZ6uumuwtcP/nsJ+FDJYM7QJ+F7+Svu0n6mpxl/55WUzzj10x8+
vEU3+W9sszRpKOnh2edLr2wbYe/kScDKSSh6yNGut54EvPt8ruzSYc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b
jb/gM+2KFwlyJpYWteepVcAJ8tniE7fdf+OU4dJvsXQv7f+kR1WGGboIt6EpYYFi
N7aDUKq7r2ivX7Gj+cRvFiFR5hV5VD5nYGY2Quw07foe+zRWPrfVx4dsgYzg1x1j
gA2C6unZEyr99oXUrpj752rk/7jTBhqvx+29CZnshOwXJQ62sIiL+EMLUbDoyQzU
5y/LhVuc
=XDPR
-----END PGP PUBLIC KEY BLOCK-----
gpg --send-keys <key-id>
). You can now use it to sign things: gpg --output <file>.sig --clearsign <file>
or to encrypt: gpg --recipient <recipient-user-id> --encrypt <file>
. You can load it into Thunderbird and sign or encrypt all your emails, sign your github commits, or just have encrypted conversations with people. Enjoy.