LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-03-2023, 03:52 AM   #1
glennbtn
Member
 
Registered: Dec 2009
Posts: 154

Rep: Reputation: 19
gpg decrypt in script


Hi All

I am having an issue automating the decryption of a file in a bash scrip..

I have a passphrase file and the 1st time I run the bash script it asks for the password, but subsequent runs of the script I don't get this and it runs ok. When added to the cron though it fails.

This is my code hopefully someone can point me in the direction I am going wrong

Code:
pass_phrase=`cat /scripts/passphrase.txt|awk '{print $1}'`
gpg --passphrase $pass_phrase --output cdr.zip --decrypt cdrext.zip.asc
This is running on Ubuntu 20.04.5 LTS & gpg (GnuPG) 2.2.19

Thanks
 
Old 01-03-2023, 04:54 AM   #2
Michael Uplawski
Senior Member
 
Registered: Dec 2015
Posts: 1,624
Blog Entries: 40

Rep: Reputation: Disabled
Why the call to awk?
 
Old 01-03-2023, 07:40 AM   #3
Turbocapitalist
LQ Guru
 
Registered: Apr 2005
Distribution: Linux Mint, Devuan, OpenBSD
Posts: 7,378
Blog Entries: 3

Rep: Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772Reputation: 3772
Quote:
Originally Posted by glennbtn View Post
I have a passphrase file and the 1st time I run the bash script it asks for the password, but subsequent runs of the script I don't get this and it runs ok. When added to the cron though it fails.
That's because your interactive session is using an agent. You ought to set up a unique, independent key agent for the cron job to use. That way you can load the key into the agent once per reboot and have the script still work. Scripting like this might be a situation where sq is easier than gpg.
 
1 members found this post helpful.
Old 07-25-2023, 10:22 PM   #4
Rouregre
LQ Newbie
 
Registered: Jul 2023
Posts: 1

Rep: Reputation: 0
Quote:
Originally Posted by Turbocapitalist View Post
That's because your interactive session is using an agent. You ought to set up a unique, independent key agent for the cron job to use. That way you can load the key into the agent once per reboot and have the script still work. Scripting like this might be a situation where sq is easier than gpg.tiny fishing
I tried and it works.

Last edited by Rouregre; 07-26-2023 at 08:05 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
mutt unable to decrypt emails "Could not decrypt PGP message" frddbbbl Linux - Software 3 07-25-2019 10:48 AM
gpg / gpg-agent -- Can't connect to /root/.gnupg/S.gpg-agent jrtayloriv Linux - Security 9 06-03-2019 10:06 AM
gpg decrypt problems bic Linux - Newbie 2 09-08-2009 10:03 PM
GPG: Bad session key gpg between gpg on linux and gpg gui on windows XP konqi Linux - Software 1 07-21-2009 09:37 AM
Can't decrypt anything with GPG Jorophose Linux - Security 2 12-06-2007 04:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 11:34 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration