LinuxmacOSWindows

Where Does GnuPG Store Keys and Config?

GnuPG keeps keyrings, trust data, and config in one home directory. The default paths on Linux, macOS, and Windows.

Last updated

GnuPG stores everything in its home directory. On Linux and macOS that defaults to ~/.gnupg. On Windows it defaults to %APPDATA%\gnupg. Keyrings, private key stubs, trust data, and config files all sit together there.

The key files are pubring.kbx for public keys, private-keys-v1.d for private key material, trustdb.gpg for owner trust, plus gpg.conf and gpg-agent.conf for settings. Permissions matter. The folder should be mode 700 with files at 600, and GnuPG complains loudly when they are looser.

Where GnuPG stores this, by platform

Linux
~/.gnupg

Standard home directory on most distros. Override with GNUPGHOME or --homedir. Files inside use 600 permissions; the folder itself uses 700.

macOS
~/.gnupg

Same layout as Linux. Homebrew and MacPorts installs both use this path unless GNUPGHOME points elsewhere.

Windows
%APPDATA%\gnupg

Roaming AppData location for Gpg4win and stock builds. You can redirect it with the HomeDir registry value under HKCU\Software\GNU\GnuPG or with GNUPGHOME.

Frequently asked questions

how do i use a different gnupg home directory

Set the GNUPGHOME environment variable or pass --homedir on the command line. On Windows you can also set the HomeDir value under HKCU\Software\GNU\GnuPG. The new folder must have strict permissions or GnuPG will warn you.

which files do i back up to keep my keys

Back up the whole home directory, especially pubring.kbx, private-keys-v1.d, trustdb.gpg, and gpg.conf. Copying single files out of context often breaks. A full directory copy restores cleanly on the same GnuPG version.

Notice an outdated path? Let us know.