GPG secret key: How to change the passphrase
- Security
- Published
- 2 min read
- @nabbisen
Table of contents
Summary Summary
Suppose you get along with GPG (opens in a new tab) (The GNU Privacy Guard, GnuPG) for good privacy, and sometimes want to change the passphrase of its secret key.
This post shows how to do it.
To be short:
- Get the secret key ID
- Run
gpg --edit-key ${the-key}to start the prompt - Run
passwd
Environment Environment
- OS: Devuan (opens in a new tab) 5 - Daedalus (opens in a new tab)
- Desktop Environment: Xfce (opens in a new tab) 4.16 (opens in a new tab)
- Cryptographic Software: GPG 2.2.40 (opens in a new tab)
- Based on the OpenPGP (opens in a new tab) standard as defined by RFC4880 (opens in a new tab)
Description Description
First, get the secret key ID by running:
$ gpg --list-secret-keys --keyid-format=long
It will print out like below:
/home/${USER}/.gnupg/pubring.kbx
---------------------------------
sec rsa4096/${KEY:LIKE-123ABC456DEF} 202X-XX-XX [SC]
${HASH}
uid [...] ${NAME} <${EMAIL}>
ssb rsa4096/${SUBKEY} 202X-XX-XX [E]
Get the key in sec.
Next, run gpg with --edit-key option and the key:
$ gpg --edit-key ${KEY:LIKE-123ABC456DEF}
Then it will show information on the key like below and start the prompt:
gpg (GnuPG) 2.2.40; Copyright (C) 2022 g10 Code GmbH
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Secret key is available.
sec rsa4096/${KEY:LIKE-123ABC456DEF}
created: 202X-XX-XX expires: never usage: SC
trust: unknown validity: unknown
ssb rsa4096/${SUBKEY}
created: 202X-XX-XX expires: never usage: E
[...] (1). ${NAME} <${EMAIL}>
gpg>
Type as below:
gpg> passwd
The current passphrase will be required:

Finally, fill the new passphrases:

Done without any output if there is no error. You can exit with:
gpg> quit
Conclusion Conclusion
This is how to change the password on GPG.
Wish you privacy protected well 😉
More on: Security for developers
-
A new sudo vulnerability was found.
-
Chrome on Windows (and more), whose version is prior to 109.0.5414.74, has risk to make remote attack easy.
-
Log4j 2.17.1 was released because a new vulnerability on RCE (Remote Code Execution) had been found in 2.17.0.
Scqr [secureal]
Scqr [secureal]: the engineering practice of Reflerd Inc. (opens in a new tab)
Comments and feedback are welcome.