The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
user login problem & Files listing problem. pernasivam AIX 1 06-18-2009 10:09 AM
Loop problem with one more problem aliahsan81 Shell Programming and Scripting 3 01-07-2009 02:02 AM
problem in finding a hardware problem girish.batra SUN Solaris 8 09-09-2008 11:10 AM
ssh script problem problem pcjandyala Shell Programming and Scripting 2 07-31-2008 04:27 PM
problem with dd command or maybe AFS problem Anta Shell Programming and Scripting 0 08-25-2006 11:10 AM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 07-01-2009
anushree.a anushree.a is offline
Registered User
  
 

Join Date: May 2008
Posts: 87
GPG Encription problem

Dear Friends,
I have been using symmetric gpg encryption. I encrypt a file as follows

gpg --symmetric <file name>

then It asks to enter password two times

Now the problme is, I have some 700 odd files to be encrypted by using symmetric gpg encription
Can u plz tell me how to do that by using "for" loop.

Thank you in advance
Anushree.a
  #2 (permalink)  
Old 07-01-2009
fpmurphy's Avatar
fpmurphy fpmurphy is offline Forum Staff  
Moderator
  
 

Join Date: Dec 2003
Location: Florida
Posts: 1,937
man gpg . Read up about the batch mode.
  #3 (permalink)  
Old 07-07-2009
anushree.a anushree.a is offline
Registered User
  
 

Join Date: May 2008
Posts: 87
gone thro the man gpg results... but unable to get the required details...
Please if anybody knows the solution kindly let me know
Thank you in advance
Anushree
  #4 (permalink)  
Old 07-07-2009
pludi's Avatar
pludi pludi is online now Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,936
From the man page (which you have of course read) some options that might be helpful:
Code:
       --batch
       --no-batch
              Use batch mode.  Never ask, do not allow  interactive  commands.
              --no-batch disables this option.

       --no-tty
              Make  sure that the TTY (terminal) is never used for any output.
              This option is needed in  some  cases  because  GnuPG  sometimes
              prints warnings to the TTY even if --batch is used.

       --passphrase-fd n
              Read the passphrase from file descriptor n. Only the first  line
              will  be  read  from  file descriptor n. If you use 0 for n, the
              passphrase will be read from stdin. This can  only  be  used  if
              only  one  passphrase is supplied.  Note that this passphrase is
              only used if the option --batch has also been  given.   This  is
              different from gpg.


       --passphrase-file file
              Read  the passphrase from file file. Only the first line will be
              read from  file  file.  This  can  only  be  used  if  only  one
              passphrase is supplied. Obviously, a passphrase stored in a file
              is of questionable security if other users can read  this  file.
              Don't  use  this  option  if  you  can avoid it.  Note that this
              passphrase is only used if the  option  --batch  has  also  been
              given.  This is different from gpg.


       --passphrase string
              Use  string as the passphrase. This can only be used if only one
              passphrase is supplied. Obviously, this is of very  questionable
              security  on  a  multi-user system. Don't use this option if you
              can avoid it.  Note that this passphrase is  only  used  if  the
              option --batch has also been given.  This is different from gpg.

  #5 (permalink)  
Old 07-10-2009
pludi's Avatar
pludi pludi is online now Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,936
Since you started a second thread for the same question (apparently) without reading the man-page, I'll provide a solution this time.


Code:
> cat pass
s3cr3t
> gpg --batch --no-tty --armor --passphrase-file pass --symmetric test.file
> ls test.*
test.file  test.file.asc
> file test.file.asc
test.file.asc: PGP armored data message

  #6 (permalink)  
Old 07-13-2009
anushree.a anushree.a is offline
Registered User
  
 

Join Date: May 2008
Posts: 87
I dont know how to use your solution.

Following is the o/p i got when I run the script

test.sh: line 1: ./pass: Permission denied
test.sh: line 2: s3cr3t: command not found
test.sh: line 3: --batch: command not found
test.sh: line 4: ./test.file: Permission denied
test.sh: line 5: ./test.file: Permission denied
test.sh: line 6: test.file.asc: command not found
test.sh: line 7: test.file.asc:: command not found
  #7 (permalink)  
Old 07-13-2009
pludi's Avatar
pludi pludi is online now Forum Staff  
Moderator
  
 

Join Date: Dec 2008
Location: .at
Posts: 1,936
That's probably because what I provided isn't a complete script, but rather an example of what it would look like when done manually. Posting again with comments to clarify:
Code:
> cat pass    # Run the 'cat' program to show the contents of file 'pass' which
              # contains the passphrase
s3cr3t        # Contents of file 'pass'
# Calling gpg in batch mode, telling it not to allocate a TTY, asking for
# ASCII-Armor output (non-binary data), providing the passphrase in file 'pass',
# symmetric enryption for file 'test.file'
> gpg --batch --no-tty --armor --passphrase-file pass --symmetric test.file
> ls test.*   # Display a listing of the original & encypted file
test.file  test.file.asc
> file test.file.asc # Run the 'file' utility to take a guess at the type of the
                     # content of file 'test.file.asc'
test.file.asc: PGP armored data message # It tells us that it's encrypted,
                                        # armored data

All you have to do is substitute the filenames I used with those you have. As soon as you've got that down, start using variables instead of filenames. And when that's done you can start with the for loop.
Reply

Bookmarks

Tags
encryption, gpg

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:04 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0