1

I use GPG keys to encrypt backups with duplicity, so I would like to export the key after it is generated, so I can move it to a backup location in case the server burst into flames.

Is there any way to export the secret key without user interaction? I can generate keys with this piece of documentation, but every time I try to export the key, it asks for password. I tried passing a environment variable like PASSPHRASE or adding --passphrase, but it still asks for the password.

Is this even possible or should I just copy the .gnupg directory and backup that instead? Every server only has one GPG key.

Trying this on Ubuntu Server 18.04 with GPG 2.2.8, by the way.

2

Related Server Fault: gpg: what do I need to backup?

Entire .gnupg directory can be backed up as files, which also brings with it public keys and your trust database. Export armor is only needed for sending to another system.

Beware that anyone who has access to your backup archive also has access to the private keys. Sometimes, this is a policy that can be allowed, sometimes not.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.