Skip to content

Import and Export private GPG keys

In open-source projects where I need to store credentials for security reasons, I use a tool called blackbox. It uses GPG keys for encryption and key management.

When I now set up a new server and need access to those keys, I need to export them. In order to do that, we first need to find the key we want to use. We can do that by using the following command:

gpg --list-keys

Once you locate your key, export one of it with those commands:

gpg --export-secret-key -a "<key holder name>" > secret.asc
gpg --export-secret-key -a <8 char key id> > secret.asc

Once you moved the secret.asc file to another machine, you can import it again:

gpg --import secret.asc

And now you are ready to use your private key on the other machine.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.