GPG: How to change/edit Private Key Passphrase?

You might forget your GPG private key’s passphrase. You need your private key’s passphrase in order to decrypt an encrypted message or document which is encrypted using your public key. So, if you lost or forgot it then you will not be able to decrypt the messages or documents sent to you.

You don’t have to worry though. You can easily change/edit/update your GPG Passphrase. This can be done using –edit-key command.

Here is a step-by-step tutorial on changing your GPG secret key passphrase:

1) Get your key ID

List all your keys with the following command:


gpg --list-keys

This should display your key as well. Here is an example of the key:

pub 2048R/C5DB61BC 2015-04-21
uid Your Name (Optional Comment)
sub 2048R/18C601D3 2015-04-21

In the above example, the key ID is C5DB61BC.

2) Edit your key

Run the following command:


gpg --edit-key your-key-ID

From the example in step 1, you can write as:


gpg --edit-key C5DB61BC

Now, run the following command:


gpg> passwd

Now, you will be asked two times to enter your new passphrase.

3) Save your passphrase

Immediately after entering your new passphrase, run the following command:


gpg> save

Finally, you have saved your new passphrase. Now, you can use this new passphrase while decrypting document or digitally signing any document.