How to store Kleopatra PGP keys on USB drive?

I'm using Kleopatra (actually gpg4win) on Windows. I've created PGP Private keys, and I would like to store them on my usb stick (e.g. be able to encrypt files only if the private key is available - that is, if the usb stick is in the drive).

How can I do this?

Thanks!


You cannot move single keys or even keypairs, but you can move the entire keyring:

  1. Move GnuPG data directory (~/.gnupg; on Windows %APPDATA%\.gnupg) to your chosen location.
    • For extra security, copy and secure-wipe instead of just moving (which does an insecure deletion).
  2. Set the GNUPGHOME environment variable to the new location.
    1. System Properties → Advanced → Environment Variables. Alternatively, in Windows 7, search for "environ" in Control Panel.
    2. Click Add, enter GNUPGHOME as name and the new path as value.
      • For example, E:\private\gnupg or C:\mnt\jwir3 flash drive\GnuPG or whatever the hell you moved your keys to.
    3. The currently running programs will not see your changes. Exception: Windows Shell (explorer.exe), which receives a change notification. So you need to close Kleopatra and restart it from the Start menu.

EDIT: Looks like it's actually the GNUPGHOME environment variable, rather than GNUPG_HOME


I tried the GNUPGHOME directory and it mostly works but if you ever have another installation of GPG all hell breaks loose and it will create some problems. A better solution I happened upon is to download and install the full gpg4win download, then run mkportable --full [somedir] to create a portable install. Copy that to your USB or truecrypt drive and then uninstall gpg. The home directory is where you copy all your existing keyring files if any.