4

I am using the GNUPG tool for performing encryption/decryption using the command line. While deleting the public key I am giving the following command : gpg2 --quite --yes --delete-key "Solveon DB"

After the command gets executed I get the question Delete this key from the keyring? (y/N)

I dont want this question to be asked. Can you suggest which option to use. I tried specifying the fingerprint but I couldn't figure out the use. 1 hour ago - 4 days left to answer. I had created a C# wrapper class to use the tool but when using delete option it hangs the application as its waiting for answer to the question. Additional Details

Link for commands: I have used the software which I downloaded from this site: http://www.gpg4win.org/

http://www.linuxguide.it/command_line/linux-manpage/do.php?file=gpg

4 Answers 4

10

use following

gpg2 --batch --yes --delete-key "Solveon DB" 

Please note that it will only work when you want to delete the public key .

Sign up to request clarification or add additional context in comments.

Comments

2

You've got a typo in your question (it's --quiet, not --quite) but this won't quiet gpg2 down completely. The option you need in this case is --batch.

To delete a key in batch mode, you'll have to specify it using the fingerprint. You can find the fingerprints for your keys with this command:

$ gpg2 --list-keys --fingerprint /home/joeschmoe/.gnupg/pubring.gpg ---------------------------------- pub 2048R/3C6033BD 2012-02-15 Key fingerprint = EA8B 7339 D8AB 608D D9B6 BFA2 797B 679C 3C60 33BD uid Joe Schmoe <[email protected]> sub 2048R/8C61295F 2012-02-15 

The fingerprint gets displayed in 4 character groups for easy reading, but when using it to identify the key to delete, drop the spaces and use just the 40 characters of the fingerprint:

$ gpg2 --batch --delete-key EA8B7339D8AB608DD9B6BFA2797B679C3C6033BD 

1 Comment

gpg: can't do this in batch mode without "--yes"
1

Here is another solution to delete all secret keys and then "user123" keys, expired and non-expired.

First script is looking for fingerprint's and make a solid numeric string form their symbols (z.B., ADFG1HJH3JHG5HGTY6KJYY6KJHKK535JNNN).

gpg --list-keys --fingerprint | grep fingerprint | cut -c 25-74 | sed 's/ //g'

Other code is clear for understanding.

#!/bin/bash function myfunc() { local SKEY=$(gpg --list-keys --fingerprint | grep fingerprint | cut -c 25-74 | sed 's/ //g') echo "$SKEY" } SKEY1=$(myfunc) #echo $SKEY1 gpg --batch --fingerprint --yes --delete-secret-key $SKEY1 <<EOF $SKEY1 EOF #rm -rf ex.txt gpg --batch --yes --delete-key "user123" 

1 Comment

Do not pay attention to string: rm -rf ex.txt It should not be there:)
1

After puzzling over this myself, I found you can use CMD to delete both public and private keys. Here's the code I used for this:

gpg --batch --yes --delete-key [keyID] gpg --batch --yes --delete-secret-key [ClientKeyID] 

Where the text+square brackets is replaced by the 40 digit key fingerprint, and the lines apply to public and private keys respectively. I call a batch file from within powershell to achieve this and it works perfectly.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.