You need to import the private key in order to use it , but the management of private keys with GnuPG version 2.x has changed. There is a gpg-agent
daemon that handles access to private keys, and its use is mandatory since version 2.1.
Here you can quickly create a temporary keychain for decryption using the secret key contained in the file:
$ mkdir -m 700 ~/.gnupg-temp $ gpg --homedir .gnupg-temp --import key.sec $ gpg --homedir .gnupg-temp -d an_ecrypted_file
If you want to clean later, stop the agent and delete the directory:
$ gpg-connect-agent --homedir .gnupg-temp KILLAGENT /bye $ rm -r ~/.gnupg-temp
There used to be the --secret-keyring
option, which documentation for version 2.1 has this to say:
This is an obsolete option and is ignored. All private keys are stored in the private-keys-v1.d directory under the GnuPG home directory.
The private-keys-v1.d
(with --homedir
or ~/.gnupg
) is owned and managed by the agent.
source share