Syntax Question on GPG2 on LINUX
Steve Butler
sbutler at fchn.com
Thu Oct 6 22:19:43 CEST 2016
Jim,
I don't use modern but I do have a script for classic that works in unattended mode on a Linux box. The caller knows the input file name and the script knows my passphrase -- default gpg_pass2. Hope this helps with gpg2! --Steve
$ cat gpg_encrypt
#!/bin/ksh
usage="gpg_encrypt [ -a -b -e ext -n -s ] PK_ID source"
#
# Interface script for edi and ftpexec to encrypt files vi GnuPG
#
# -a Use Ascii Armor (--armor switch)
# -b Use binary (e.g. opposite of -a)
# -e Use ext as value of file extension (defaults to pgp when not specified)
# -n Do not sign (e.g. opposite of -s)
# -s Sign using key for helpdesk at fchn.com as signing key
# For conflicting options, the last one entered takes precedence.
#
# PK_ID Key ID to which the file is to be encrypted.
# source Source file name to encrypt.
#
# Encryptes to a file of source.ext and name is echoed to stdlist
XRG_DBA=${XRG_DBA:=/usr/xrg_dba}
xrgbin=$XRG_DBA/bin
homedir=$($xrgbin/default gpg_home)
EXT=pgp
ARMOR=""
SIGN="--sign"
while getopts ":abe:ns" opt
do
case $opt in
a) ARMOR="--armor" ;;
b) ARMOR="" ;;
e) EXT=$OPTARG ;;
n) SIGN="" ;;
s) SIGN="--sign" ;;
*) echo $usage
exit 2
;;
esac
done
shift $(($OPTIND - 1))
if [[ $# -ne 2 ]]; then
echo "gpg_encrypt: Must supply 2 parameters" >&2
echo " usage: $usage" >&2
exit 99
fi
rm -f "$2.$EXT" > /dev/null
if [[ -z $SIGN ]]; then
gpg --batch --homedir $homedir --quiet --no-tty --always-trust $ARMOR \
--no-permission-warning --recipient $1 --output "$2.$EXT" --encrypt "$2"
x=$?
else
$xrgbin/default gpg_pass2 | gpg \
--batch --homedir $homedir --quiet --no-tty --always-trust $ARMOR \
--sign --passphrase-fd 0 --default-key helpdesk at fchn.com \
--no-permission-warning --recipient $1 --output "$2.$EXT" --encrypt "$2"
x=$?
fi
if [ $x -ne 0 ]; then
echo "gpg_encrypt: gpg failure code '$x'" >&2
fi
echo "$2.$EXT"
exit $x
#
From: Gnupg-users [mailto:gnupg-users-bounces at gnupg.org] On Behalf Of Jim Ernst
Sent: Thursday, October 06, 2016 5:39 AM
To: gnupg-users at gnupg.org
Subject: Syntax Question on GPG2 on LINUX
Hello All -
I am working in a LINUX environment using GPG version 2.1.15
Can anyone give me the syntax to use gpg2 to create a signed, encrypted file using a passphrase in a LINUX shell script ? This is being run from Oracle EBS on a schedule so there would not be a user interacting to answer prompts. With this mode, is there any terminal settings I would need to set ?
Thanks !!
Jim Ernst
NTT Data
NOTE: The sender of this email is an independent contractor of Invacare Corporation or one of its subsidiaries. CONFIDENTIALITY NOTICE: The information in this e-mail message and any attachments may contain privileged, confidential or proprietary information, including confidential health information, protected by applicable Federal or state laws. Such information is intended only for the recipient named above. If you are not the intended recipient, please notify the sender immediately, and take notice that any use, disclosure or distribution of such information is prohibited by law.
--
CONFIDENTIALITY NOTICE: This e-mail message, including any attachments,
is for the sole use of the intended recipient(s) and may contain
confidential
and privileged information. Any unauthorized review, use, disclosure or
distribution is prohibited. If you are not the intended recipient, please
contact the sender by reply e-mail and destroy all copies of the original
message.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: </pipermail/attachments/20161006/705da483/attachment-0001.html>
More information about the Gnupg-users
mailing list