Skip to content

Instantly share code, notes, and snippets.

@asconix
Forked from chrisswanda/Moving_gpg_keys.txt
Created November 25, 2021 12:16
Show Gist options
  • Save asconix/2802ce4ecd2c14953e59b327bc7ea9cb to your computer and use it in GitHub Desktop.
Save asconix/2802ce4ecd2c14953e59b327bc7ea9cb to your computer and use it in GitHub Desktop.
Moving GPG keys to new machine
Mac and Linux work the same, storing the keys in ~/.gnupg. The safest way to transfer the files is using scp (part of ssh):
To copy from your local machine to another:
scp -rp ~/.gnupg othermachine:
To copy from a remote machine to your local:
scp -r othermachine:~/.gnupg ~
If you're on the machine that already has the key:
gpg --export-secret-key SOMEKEYID | ssh othermachine gpg --import
If you're on the machine that needs the key:
ssh othermachine gpg --export-secret-key SOMEKEYID | gpg --import
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment