LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-13-2005, 11:12 AM   #1
rblampain
Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 7
Posts: 833

Rep: Reputation: 35
bash & gpg/pgp


I need to implement the option --passphrase-fd n of GPG/PGP.
Doing the encrypting/decrypting in bash takes only a couple of lines but I can't find out how to pass the file descriptor (n) to the GPG command. It will be 3 but how do I open the file?

Could anyone show me how?

Thank you.
 
Old 08-13-2005, 02:28 PM   #2
traene
Member
 
Registered: Jan 2005
Distribution: Archlinux, Debian, grml
Posts: 210

Rep: Reputation: 33
Maybe i don't fully understand your problem. you may call gpg with all options necessary. When you need to add a file list you may finish your options list with '--' and give the file list.
 
Old 08-14-2005, 12:16 AM   #3
rblampain
Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 7
Posts: 833

Original Poster
Rep: Reputation: 35
That was very clumsy of me, I forgot to mention I want to automate the process with a "bash" script.

In my case 2 files will have to be passed to the (bash) command, the first file is the one containing the passphrase and the second is the file to be encrypted.

My question was how to pass the file containing the passphrase since GPG expects it in the form of "n" in "--passphrase-fd n".

Obviously it has to be 3 or higher since 0,1 and 2 are taken by stdin, stdout and stderr.

I hope my question makes sense now.
 
Old 08-16-2005, 01:03 AM   #4
rblampain
Member
 
Registered: Aug 2004
Location: Western Australia
Distribution: Debian 7
Posts: 833

Original Poster
Rep: Reputation: 35
For anyone interested:
The following commands work, I had these in a bash script. The first command encrypts while the second one decrypts, both without asking for the passphrase. This was done AFTER removing all the keys. No keys are necessary.

gpg --symmetric --batch --passphrase-fd 0 <pass --output encrypted encrypthis

gpg --batch --passphrase-fd 0 <pass -d --output decrypted encrypted

a check shows that the files "encrypthis" and "decrypted" are Identical.

"pass" is a file holding the passphrase and --passphrase-fd 0 expect it to be redirected to it as above or "piped" through "cat" or similar.

I also had a string of 32 bytes of mixed characters (letters, numbers and others) that I found gpg considered as an invalid passphrase.

Hope this is useful to someone.

Last edited by rblampain; 08-16-2005 at 01:04 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
KMail and PGP/GPG not working - doesn't ask for passphrase steve1401 Linux - General 2 02-08-2005 06:42 AM
why did bash 2.05b install delete /bin/bash & "/bin/sh -> bash"? johnpipe Linux - Software 2 06-06-2004 06:42 PM
PGP & Kmail BashTin Linux - Software 9 04-09-2004 11:38 AM
How does GPG relate to PGP? davee Linux - Security 1 02-20-2004 07:52 AM
gpg / pgp encryption pteren Linux - Software 8 07-26-2003 03:14 AM


All times are GMT -5. The time now is 10:51 PM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration