Import/Export GPG key pair

$ gpg --list-keys
pub 1024D/ABCDFE01 2008-04-13
uid firstname lastname (description) <>
sub 2048g/DEFABC01 2008-04-13

Export key ABCDFE01:

$ gpg --output gpgkey_pub.gpg --armor --export ABCDFE01
$ gpg --output gpgkey_sec.gpg --armor --export-secret-key ABCDFE01

Optionally, use scp to copy those files to a remote host:

$ scp gpgkey_pub.gpg gpgkey_sec.gpg user@remotehost:~/

On the “import host”:

$ gpg --import ~/gpgkey_pub.gpg
$ gpg --import ~/gpgkey_sec.gpg

Don't forget to remove the exposed keys:

$ rm ~/gpgkey_*
  • sysadmin/kb/import_export_gpg_key_pair.txt
  • Last modified: 2019/10/10 20:56
  • by mjorgensen