How to copy GPG key from one machine to another

If you’re taking work from others on the internet and want to verify that commits are actually from a trusted source, Git has a few ways to sign and verify work using GPG. If you want to copy GPG keys from one machine to another you have to export public and private GPG keys and move them to the new machine.

  1. Command to list keys: gpg —list-keysgpg --list-keys
  2. Commands to export keys:
    gpg —export ${ID} > public.key
    gpg —export-secret-key ${ID} > private.key
    gpg --export
  3. Move files to the new machine;
  4. Commands to import keys:
    gpg —import public.key
    gpg —import —allow-secret-key-import private.key

Author: pbazeliuk

Добавить комментарий