I'm setting up some keys for our team. I want to make a bash script that will sign all the (known) keys that I have just imported. I want to sign the keys without prompts (non-interactive).

Here's what I have.

for key in $(gpg2 -k --with-colons | grep pub: | cut -d ":" -f 5); do
  gpg2 --fingerprint $key
  # TODO: check if the key is already signed; if not, sign it
  gpg2 --batch --yes --sign-key $key

The above is missing a check (which is not critical as gpg2 seems to do the right thing if the key is already signed). But more importantly it also fails to answer some prompts with "yes".

The other related questions all involved answers that required interactivity (except in one case which used xdotool to enter keystrokes, and which I don't find satisfactory).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.