Skip to content

Instantly share code, notes, and snippets.

@k-f-
Forked from chrisswanda/Moving_gpg_keys.txt
Created January 1, 2022 16:06
Show Gist options
  • Save k-f-/8477716d00680e2067a6f22136efea4b to your computer and use it in GitHub Desktop.
Save k-f-/8477716d00680e2067a6f22136efea4b 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