Copying GnuPG keys to a new computer

2

1

I want to transfer all my GnuPG keys from a computer with Ubuntu to one with Fedora. I wonder if I can just copy all the keys in the .gnupg folder and then import them on the Fedora computer or if is better to use --export with --output? I have practiced this in the past, but it took so much trial and error, I am afraid I might do it the wrong way and lose data. I would appreciate a sample command for export of multiple(2) keys to files if that is the way to go.

summertime

Posted 2017-12-15T13:18:00.283

Reputation: 23

Answers

5

If you also want to copy your secret keys, run both --export and --export-secret-keys and start with importing the secret keys. Also don't forget to migrate trust (--export-ownertrust/--import-ownertrust).

The easier way might be to just copy the whole GnuPG home directory including configuration, keyrings and trust to the new machine (~/.gnupg/), don't forget to preserve permissions. If your user ID (the numerical ID, not the name) changed, run sudo chown -R $USER:$USER ~/.gnupg afterwards to take ownership of the files.

If you are scared about data loss: as long as you just copy the files from your old computer (and don't change them there), you can start from scratch at any time. Also -- you've got an up-to-date backup of your files anyway, haven't you?

Jens Erat

Posted 2017-12-15T13:18:00.283

Reputation: 14 141