Export both a Public and Private Key

Exporting your private key is useful because you will want to create a backup should your system somehow become unavailable or experience a problem. To create a backup of all keys to a single file, issue the following command:

$ gpg --export -o gpg_backup_file

If, for example, your username were James Stanger, the following command would export only your private key to a file named private.key:

$ gpg --export-secret-key -a "James Stanger" -o private.key

To export your public key, you would issue the following command:

$ gpg -- export-public-key -a "James Stanger" -o stanger.pub

Get LPI Linux Certification in a Nutshell, 3rd Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.