I have a script that basically needs to do the following:#!/bin/bash GPG_PUBLIC_KEY=<<EOF-----BEGIN PGP PUBLIC KEY BLOCK-----Version: GnuPG v1.4.12 (GNU/Linux)...-----END PGP PUBLIC KEY BLOCK-----EOFgpg --encrypt --with-public-key $GPG_PUBLIC_KEY myfile.txtIs there a way to do this without importing the GPG key to the keyring first?
Is there a way to embed a GPG public key in a script without adding it to the keyring?
shell script;gpg
If you don't want to use the user's keyring at all, point GPG to a temporary keyring.tmp=trap 'rm -rf $tmp' EXIT INT TERM HUPtmp=$(mktemp -d)export GNUPGHOME=$tmpgpg --import <<EOFEOFgpg -e -r  myfile.txtIf you want to use the user's keyring as well, set GNUPGHOME only during the import command and pass --keyring $tmp/pubring.gpg to the second gpg command.