How to Delete GPG Keys | phoenixNAP KB (2024)

Introduction

GPG keys are an implementation of the OpenPGP standard for secure communication and data integrity. Deleting GPG keys is sometimes necessary for security maintenance and key expiration management.

In this article, you will learn how to delete GPG keys using different methods.

How to Delete GPG Keys | phoenixNAP KB (1)

Prerequisites

  • A Linux system (this tutorial uses Ubuntu 22.04).
  • An existing GPG Keys set.

GPG Key Types

There are two types of GPG keys:

  • Public keys. This type of key ensures data encryption and is used to validate the origin of a message. Public keys are meant to be shared openly as the message can be decrypted only with the corresponding private key.
  • Private keys. This type of key should be kept confidential for security reasons. A single private key is paired with a single public key counterpart and both are necessary for authentication and decryption.

How to List GPG Keys in Linux

Before deleting GPG keys on Linux, list them with the gpg command to verify the User ID (uid) and KeyID.

To list public keys in Linux, run:

gpg --list-keys
How to Delete GPG Keys | phoenixNAP KB (2)

The gpg --list-keys output includes the following information:

  • pub. Indicates the key type (i.e., algorithm used) creation and expiration date, and capability (SC).
  • KeyID. A unique identifier displayed as a hexadecimal value.
  • uid. Indicates the user ID, trust level (ultimate), username, and associated email.
  • sub. Subkey information and relevant details.

To list private keys, use gpg with the --list-secret-keys option:

gpg --list-secret-keys
How to Delete GPG Keys | phoenixNAP KB (3)

The output is similar to the gpg --list-keys output but displays the private keys associated with different users. The structure and components in the output remain the same.

Still, different signifiers are used:

  • sec. Indicates the type of key (private key).
  • ssb. Represents the secret subkey associated with the primary private key.

Note: If the system has no GPG keys, the gpg command has no output.

How to Delete GPG Keys in Linux

There are two approaches to deleting GPG keys: the User ID (uid) or the KeyID. Both options enable users to delete GPG keys for single or multiple users.

Warning: To ensure successful key removal, delete the Private key first and then proceed with deleting the Public key.

Delete Keys of a Single User

To remove the GPG keys of a single user, use gpg with appropriate options.

Using UserID

The syntax for deleting the Private GPG key for a single user using the uid is:

gpg --delete-secret-key [uid]

On the other hand, to delete the public GPG key, the syntax is:

gpg --delete-key [uid]

For instance, to delete the GPG keys of user1:

1. Find the user1 uid in the gpg --list-secret-keys output.

How to Delete GPG Keys | phoenixNAP KB (4)

The uid for the chosen key is user1.

2. Run this command:

gpg --delete-secret-key user1

3. Type y to confirm.

How to Delete GPG Keys | phoenixNAP KB (5)

4. Type y again to confirm.

How to Delete GPG Keys | phoenixNAP KB (6)

5. Click Delete key on the first popup message.

How to Delete GPG Keys | phoenixNAP KB (7)

6. Click Delete key on the second popup message to delete the subkey.

How to Delete GPG Keys | phoenixNAP KB (8)

7. Delete the user1 Public key with:

gpg --delete-key user1

Type y to confirm.

8. Verify the keys are deleted:

gpg --list-keys
How to Delete GPG Keys | phoenixNAP KB (9)

The output shows the user1 Public key is missing. Run gpg with the option to list Private keys to complete the verification:

gpg --list-secret-keys
How to Delete GPG Keys | phoenixNAP KB (10)

The output does not show the Private key for user1, confirming its removal.

Using KeyID

Another way to delete GPG keys is by using the KeyID.

However, the KeyID is the same for the Private and Public keys for the same user. Therefore, to locate the KeyID, check out either the gpg --list-secret-keys or gpg --list-keys output.

The example below shows the KeyID for user2 in the gpg --list-secret-keys output:

How to Delete GPG Keys | phoenixNAP KB (11)

The syntax for deleting the Private key with the KeyID is:

gpg --delete-secret-key [Key_ID]

The syntax to delete the Public key using KeyID is:

gpg --delete-key [Key_ID]

For instance, to delete the user2 Private GPG key:

1. Use the KeyID in the following command:

gpg --delete-secret-key 419F3FC847287FAF0BDA38E727BD4C0A4AE14931

2. Type y on both prompts to confirm the removal.

How to Delete GPG Keys | phoenixNAP KB (12)

3. Click the Delete key button.

4. Delete the user2 Public key with:

gpg --delete-key gpg 419F3FC847287FAF0BDA38E727BD4C0A4AE14931

5. Type y when prompted.

How to Delete GPG Keys | phoenixNAP KB (14)

To verify the removal, list all the Private and Public keys.

1. Confirm the Private key is removed with:

gpg --list-secret-keys
How to Delete GPG Keys | phoenixNAP KB (15)

2. Confirm the Public key is removed with:

gpg --list-keys
How to Delete GPG Keys | phoenixNAP KB (16)

Delete Keys of Multiple Users

The gpg command also deletes the GPG keys of multiple users at once. Moreover, the removal is possible using uids or KeyIDs.

Using UserID

To remove the GPG keys for multiple users using the uids, delete the secret keys first with:

gpg --delete-secret-key [uid1] [uid2]

Next, delete the Public keys. The syntax is:

gpg --delete-key [uid1] [uid2]

For instance, to delete the user3 and user4 Private keys using the uids:

1. Enter this command:

gpg --delete-secret-key user3 user4
How to Delete GPG Keys | phoenixNAP KB (17)

The gpg command deletes the keys in the order stated in the command, starting with the user3 first.

2. Type y both times to confirm.

How to Delete GPG Keys | phoenixNAP KB (18)

3. Click the Delete key button.

How to Delete GPG Keys | phoenixNAP KB (19)

4. Choose the Delete key button to remove the subkey.

How to Delete GPG Keys | phoenixNAP KB (20)

Once the first Private key is deleted, the terminal prints the prompt for deleting the second one.

How to Delete GPG Keys | phoenixNAP KB (21)

5. Type y to initialize the removal process and once again to confirm.

How to Delete GPG Keys | phoenixNAP KB (22)

6. Click Delete key on both popup messages

7. To finalize the process and delete the Public key, run:

gpg --delete-key user3 user4

8. Type y to delete the Public key for user 3.

How to Delete GPG Keys | phoenixNAP KB (23)

9. Type y to delete the Public key for user4.

How to Delete GPG Keys | phoenixNAP KB (24)

To confirm all the changes, list all the Public and Private keys again.

Using KeyID

Deleting multiple GPG keys is also possible via KeyIDs. To delete multiple Private GPG keys using the KeyIDs, run the following:

gpg --delete-secret-key [Key_ID1] [Key_ID2]

Next, delete the Public keys with:

gpg --delete-key [Key_ID1] [Key_ID2]

For instance, to delete the Private GPG keys for user5 and user6:

1. Enter this command:

gpg --delete-secret-key 7199892788DE9ADD55F074F1B7995EE330164061 19C21D7D0AEB8F8DC4ADC0453E540231B586BF23

2. Type y both times to delete the Private key and confirm the removal for the user5.

How to Delete GPG Keys | phoenixNAP KB (25)

3. Click Delete key.

How to Delete GPG Keys | phoenixNAP KB (26)

4. Click Delete key to remove the subkey.

How to Delete GPG Keys | phoenixNAP KB (27)

5, Type y both times to delete user6 Private key and confirm the removal.

How to Delete GPG Keys | phoenixNAP KB (28)

6. Click the Delete key button on both popup messages.

7. Delete the Public keys with:

gpg --delete-key 7199892788DE9ADD55F074F1B7995EE330164061 19C21D7D0AEB8F8DC4ADC0453E540231B586BF23

8. Type y to delete the Public key for user5.

How to Delete GPG Keys | phoenixNAP KB (29)

9. Type y to delete the Public key for the user6.

How to Delete GPG Keys | phoenixNAP KB (30)

Run gpg --list-keys and gpg --list-secret-keys to confirm the removal.

Conclusion

In this article, you have learned how to delete gpg keys using different methods.

Next, learn about SSH keys, another Linux component with a crucial role in enhancing security and encryption.

How to Delete GPG Keys | phoenixNAP KB (2024)

FAQs

How do I delete gpg keys? ›

Yes, it is possible to delete a GPG (GNU Privacy Guard) key using a command line interface. You can use the gpg –delete-secret-key command followed by the KeyID or key fingerprint to delete the secret key and gpg –delete-key command followed by the KeyID or key fingerprint to delete the public key.

How do you clean up gpg? ›

gpg-cleanup tries to identify those public keys and help you delete them within a reasonable amount of time. It lets you first create a cache file over night or over the weekend. After you created the cache file, you run gpg-cleanup again to interactively delete all suspicious keys from your public keyring.

How do I delete all Pacman keys? ›

Resetting all the keys

Remove or reset all the keys installed in your system by removing the /etc/pacman. d/gnupg directory (as root) and by rerunning pacman-key --init followed by pacman-key --populate to re-add the default keys.

How do I remove my gpg APT key? ›

Once you have figured out which key to remove, use the command sudo apt-key del <keyid> where <keyid> is replaced with the actual keyid of the key you want to remove from your keyring.

How do I remove my GPG private key password? ›

5 Answers
  1. Open the gpg key edit submenu like this: gpg --edit-key XXXX. ...
  2. Type passwd at the prompt to change the password: gpg> passwd.
  3. Enter your existing passphrase.
  4. Enter the new passphrase for this secret key. ( ...
  5. Press Enter twice and consider the warnings from the tool and its implications before proceeding.
Sep 21, 2018

How do I uninstall GPG on Windows? ›

Using Microsoft Windows' dashboard tools: Open Start -> Settings -> Control panel -> Software and select GnuPG for Windows. Activating [Remove] will uninstall all Gpg4win program components from your operating system. Another way of uninstalling Gpg4win is to use the exe file gpg4win-uninstall.exe.

How do I list all GPG keys? ›

Open Terminal . Use the gpg --list-secret-keys --keyid-format=long command to list the long form of the GPG keys for which you have both a public and private key. A private key is required for signing commits or tags.

How do I remove my identity from GPG key? ›

To delete a user ID double click you sec/pub key in GPG Keychain, open the user ID tab and right click the user ID you want to remove and then select Remove.

How to edit gpg key? ›

How to edit GPG key?
  1. Use the command adduid to add a user-uid.
  2. Use the command addkey to create a subkey under your key.
  3. Use the command deluid to delete selected user-ids from your key.
  4. Use the command delkey to delete selected subkeys from your key.
Feb 27, 2017

How do you clean pacman in Arch Linux? ›

  1. Clean pkg cache. List packages. ls /var/cache/pacman/pkg/ | less. Remove all pkg except those installed sudo pacman -Sc. Remove all files sudo pacman -Scc. ...
  2. remove unused packages. List unused sudo pacman -Qtdq. Remove unused sudo pacman -R $(pacman -Qtdq)
  3. Clean home cache. cache is located in ~/.cache.
  4. Config Files.

Where are pacman keys stored? ›

More complex keyring management can be achieved using GnuPG directly combined with the --homedir option pointing at the pacman keyring (located in /etc/pacman. d/gnupg by default).

How do I delete all PGP keys? ›

Proper way to remove imported PGP keys
  1. Delete the key with gpg --delete-secret-key <key_id>
  2. Delete the private key and then the public key.
Jan 7, 2024

How to remove all gpg keys from git? ›

How to remove GPG key from GitHub
  1. Perhaps git config --global --unset user. signingkey ? – Mincong Huang. ...
  2. It was first thing I did. But thanks. – user9578094. ...
  3. Git configuration has 2 scopes: global scope and project scope. My command unset the global one, but you might also need to unset the project one.
Jun 10, 2018

What is the command to delete GPG key in Linux? ›

The gist
  • --delete-keys to remove a key from the public keyring;
  • --delete-secret-keys to remove a key from the secret keyring;
  • --delete-secret-and-public-key to remove a key from the public key after removing the corresponding secret key from the secret keyring, if it exists.
Nov 16, 2023

How do I remove GPG from Git? ›

Deleting your GPG Key

You can delete your key via terminal with the command gpg --delete-secret-keys simply append your username or key ID.

How to revoke GPG key Linux? ›

2 Answers
  1. List keys gpg --list-keys.
  2. Revoke your key gpg --output revoke.asc --gen-revoke key-ID.
  3. Import revocation certificate into your keyring gpg --import revoke.asc.
  4. Search your key on the key-server gpg --keyserver pgp.mit.edu --search-keys key-ID.
Feb 18, 2020

How do I disable GPG key? ›

Open GPG Keychain and double click the key you want to disable. In the key details enable the 'Disable' option. The disabled key can not encrypt or sign new messages. You can still decrypt messages with a disabled secret key.

Top Articles
NCI Dictionary of Cancer Terms
Can the WiFi owner see what I search? IPVanish
Maxtrack Live
Patreon, reimagined — a better future for creators and fans
Sound Of Freedom Showtimes Near Governor's Crossing Stadium 14
Bashas Elearning
Here are all the MTV VMA winners, even the awards they announced during the ads
Bucks County Job Requisitions
Unlocking the Enigmatic Tonicamille: A Journey from Small Town to Social Media Stardom
Craigslistdaytona
Blue Ridge Now Mugshots Hendersonville Nc
Zürich Stadion Letzigrund detailed interactive seating plan with seat & row numbers | Sitzplan Saalplan with Sitzplatz & Reihen Nummerierung
Washington Poe en Tilly Bradshaw 1 - Brandoffer, M.W. Craven | 9789024594917 | Boeken | bol
United Dual Complete Providers
Craigslist Mpls Cars And Trucks
Tcgplayer Store
Abortion Bans Have Delayed Emergency Medical Care. In Georgia, Experts Say This Mother’s Death Was Preventable.
Spergo Net Worth 2022
St Maries Idaho Craigslist
Craigslist Free Stuff Merced Ca
Aldine Isd Pay Scale 23-24
Rural King Credit Card Minimum Credit Score
Blue Rain Lubbock
Myhr North Memorial
Zillow Group Stock Price | ZG Stock Quote, News, and History | Markets Insider
Riversweeps Admin Login
Craiglist.nj
Pawn Shop Moline Il
Timeline of the September 11 Attacks
27 Modern Dining Room Ideas You'll Want to Try ASAP
Downtown Dispensary Promo Code
Roseann Marie Messina · 15800 Detroit Ave, Suite D, Lakewood, OH 44107-3748 · Lay Midwife
Barbie Showtimes Near Lucas Cinemas Albertville
Gus Floribama Shore Drugs
Diggy Battlefield Of Gods
Ucm Black Board
How to Watch the X Trilogy Starring Mia Goth in Chronological Order
The 38 Best Restaurants in Montreal
Bismarck Mandan Mugshots
Сталь aisi 310s российский аналог
How Does The Common App Work? A Guide To The Common App
Www.craigslist.com Waco
LoL Lore: Die Story von Caitlyn, dem Sheriff von Piltover
Senior Houses For Sale Near Me
Muni Metro Schedule
Egg Inc Wiki
SF bay area cars & trucks "chevrolet 50" - craigslist
Fresno Craglist
Charlotte North Carolina Craigslist Pets
Arnold Swansinger Family
Competitive Comparison
Latest Posts
Article information

Author: Prof. An Powlowski

Last Updated:

Views: 6308

Rating: 4.3 / 5 (64 voted)

Reviews: 95% of readers found this page helpful

Author information

Name: Prof. An Powlowski

Birthday: 1992-09-29

Address: Apt. 994 8891 Orval Hill, Brittnyburgh, AZ 41023-0398

Phone: +26417467956738

Job: District Marketing Strategist

Hobby: Embroidery, Bodybuilding, Motor sports, Amateur radio, Wood carving, Whittling, Air sports

Introduction: My name is Prof. An Powlowski, I am a charming, helpful, attractive, good, graceful, thoughtful, vast person who loves writing and wants to share my knowledge and understanding with you.