4

When performing an automated server deployment, I can upload and import gpg keys via script. But I cannot trust keys.

I tried

gpg --batch --yes --edit-key keyname trust 5

and

echo 5 | gpg --batch --yes --edit-key keyname trust -

In non-batch mode it always stops to ask for input. In batch mode it ignores input.

What is the correct syntax?

lonix
  • 896
  • 10
  • 23

2 Answers2

5

get fingerprint for key "keyname":
FP=$(gpg --list-keys keyname | head -n2 | tail -n1 | tr -d '[:blank:]')

trust key:
echo -e "5\ny\n" | gpg --command-fd 0 --edit-key "$FP" trust

lonix
  • 896
  • 10
  • 23
0
$ fingerprint=`gpg --fingerprint --with-colons b@gmail.com \
    | awk -F: '/^pub:/ {getline; print $10}'`
$ gpg --quick-sign-key "$b_fingerprint"

Determining a fingerprint is taken from here. A bigger example can be found here.

x-yuri
  • 2,141
  • 2
  • 24
  • 29