Search code examples
gitpgpgnupg

How do I use an old GPG key when I switch machines or work on different platforms?


I currently have "signing Git commits with GPG keys" as part of my workflow.

I'm wondering how I can use my old signature on new computers or OSes.


Solution

  • Using GnuPG, you can easily export your secret keys using

    gpg -a --export-secret-keys [key-id] >key.asc
    

    and subsequently import them on another computer (gpg --import key.asc).

    Especially for signing work, using multiple subkeys for multiple machines is recommended. If one of the computers is compromised, you can easily revoke a subkey without losing certifications.