gpg --delete-secret-keys creates lock that precents signing operations

gpg_dude's Avatar

gpg_dude

24 Aug, 2026 03:27 PM

I have a script that temporarily decrypts a file containing a secret key and then imports it into the keyring so it can be used and then deletes it so it's not stored unencrypted long-term. After the import, the --delete-secret-keys command is issued and left in a terminal waiting for confirmation: Delete this key from the keyring? (y/N). Then I would go into GPG Keychain and use the key for signing before returning to the terminal to answer this prompt and the next 3 that follow it: This is a secret key! - really delete? (y/N)` and the same 2 prompts in sequence but formatted in (n)curses. This workflow used to succeed, but at some point it stopped working unless I answer "no" to the prompts so the --delete-secret-keys command stops running and its lockfile is cleared. Is this expected behavior and/or did something change upstream that causes this? I'm currently on 3629n, but think it's been around for a few releases before that already.

Reply to this discussion

Internal reply

Formatting help / Preview (switch to plain text) No formatting (switch to Markdown)

Attaching KB article:

»

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.

Keyboard shortcuts

Generic

? Show this help
ESC Blurs the current field

Comment Form

r Focus the comment reply box
^ + ↩ Submit the comment

You can use Command ⌘ instead of Control ^ on Mac