<div dir="auto"><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">Hi</p><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">Please keep me in CC as I think I am not a  subscribed user yet.</p><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">GPG:</p><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">I am using the gpg command in a UNIX Shell script triggered by the Abinitio ETL Tool to decrypt my encrypted source files. I am following below steps to achieve my goal.</p><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">Step 1. As a POC, I can successfully executed below command.<br>gpg --batch --yes --quiet --always-trust -o /home/output_file.dat -d /etl/inbound/encrypted_file.dat.pgp</p><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">The above command will simply ask for password and decrypt the source file.<br>Please note that I am intentionally not using --passphrase as password will be exposed to console using ps command.</p><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">Step 2. Instead, I have thought of storing the passphrase in a file (passphrase.dat.pgp), encrypted that file without password and passing the password to do the work using below command.</p><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">echo <code style="margin:0px;padding:0px 5px;border:1px solid rgb(214,214,214);background-color:rgb(239,239,239)">gpg --batch --yes --quiet --always-trust -d /home/sharma43/passphrase.dat.pgp</code> | gpg --batch --yes --quiet --always-trust -o /home/output_file.dat -d /etl/inbound/encrypted_file.dat.pgp</p><h2 style="margin:2em 0px;padding:0px;font-size:12px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)"><a name="now-the-problem-comes-when-i-execute-above-command-and-it-fails-for-below-error-" href="https://gpgtools.tenderapp.com/discussions/nightly/2094-gpg-command-failing-for-no-secret-key?anon_token=c5d07b882#now-the-problem-comes-when-i-execute-above-command-and-it-fails-for-below-error-" style="margin:0px;padding:0px;outline:none;color:rgb(0,111,187)"></a>Now the problem comes when I execute above command and it fails for below error.</h2><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">gpg: cancelled by user</p><h2 style="margin:2em 0px;padding:0px;font-size:12px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)"><a name="gpg-decryption-failed-no-secret-key-" href="https://gpgtools.tenderapp.com/discussions/nightly/2094-gpg-command-failing-for-no-secret-key?anon_token=c5d07b882#gpg-decryption-failed-no-secret-key-" style="margin:0px;padding:0px;outline:none;color:rgb(0,111,187)"></a>gpg: decryption failed: No secret key</h2><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">Obviously, I have the required secret key as the POC done in Step 1 was successful.</p><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">Step 3. To my wonder, when I execute Step 1 first and then Step 2 (within a short span), it works, but if I directly run Step 2 ( which actually will be happening as a part of solution), then it doesn't and fails for "No secret key" error.</p><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">Can you please explain why this could be happening? Is there a specific location where GPG private keys should be imported?</p><p style="margin:1em 0px;padding:0px;font-family:"helvetica neue",helvetica,arial,sans-serif;background-color:rgb(255,255,255)">Please note the version I am using is "gpg (GnuPG) 2.0.22 version".</p><div data-smartmail="gmail_signature">-Regards<br>Abhisht Sharma<br>+61 420410228</div></div>