Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I expect the following command to extract the gpg file without asking for password:

  gpg --passphrase 1234 file.gpg

But it asks for the password. Why?

This also have the same behavior:

  gpg --passphrase-file passfile.txt file.gpg

I use Ubuntu with gnome 3, and remember that it was working in Fedora

share|improve this question
1  
Are you sure gpg run the right command, not an alias nor a wrapper? Try /usr/bin/gpg --passphrase 1234 file.gpg , type gpg , gpg --version and set | grep '^.\{0,9\}PG' –  F. Hauri Jan 8 '13 at 20:07
add comment

5 Answers

Ok, looking that:

$ gpg --version
gpg (GnuPG) 1.4.10
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: ~/.gnupg
Algorithmes supportés:
Clé publique: RSA, RSA-E, RSA-S, ELG-E, DSA
Chiffrement: 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH, CAMELLIA128, 
             CAMELLIA192, CAMELLIA256
Hachage: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Non-compressé, ZIP, ZLIB, BZIP2

Trying:

$ newdir=$(mktemp -d)
$ cd $newdir
$ seq 1 10 | gpg -c --passphrase 1234 -o file.gpg -
$ ls -ltr
total 4
-rw-r--r-- 1 user user 61  6 jan 14:55 file.gpg
$ hd file.gpg 
00000000  8c 0d 04 03 03 02 cf 1a  30 c8 cb 08 e0 91 60 c9  |........0.....`.|
00000010  2c 6f 3b 41 74 8f 42 cb  4e 64 cd be 94 77 c2 20  |,o;At.B.Nd...w. |
00000020  a8 b9 d6 eb df e5 60 d2  a3 99 69 2a 71 a0 38 59  |......`...i*q.8Y|
00000030  34 8b 50 1b 95 6d 87 d5  9b 93 69 fc b9           |4.P..m....i..|

sound good! Well, now:

$ gpg -d --passphrase 1234 file.gpg 
gpg: CAST5 encrypted data
gpg: encrypted with 1 passphrase
1
2
3
4
5
6
7
8
9
10
gpg: WARNING: message was not integrity protected

While no -d parameter is given (same syntaxe as SO's question), decrypted datas from file.gpg will be extracted to a new file.

$ gpg --passphrase 1234 file.gpg
gpg: CAST5 encrypted data
gpg: encrypted with 1 passphrase
gpg: WARNING: message was not integrity protected

$ ls -ltr
total 8
-rw-r--r-- 1 user user 64  6 jan 15:24 file.gpg
-rw-r--r-- 1 user user 21  6 jan 15:41 file

$ cat file
1
2
3
4
5
6
7
8
9
10

This work well!

$ cd -
$ rm -fR $newdir
$ unset newdir

I could not reproduce the SO's question environment. :-(

share|improve this answer
add comment

I am in your exact same boat (it worked on Fedora but not Ubuntu). Here is an apparent work around I discovered:

echo your_password | gpg --passphrase-fd 0 your_file.gpg

Explanation: Passing 0 causes --passphrase-fd to read from STDIN rather than from a file. So, piping the passphrase will get --passphrase-fd to accept your specified password string.

share|improve this answer
add comment

It sounds like you're using gpg2. You need to throw in the --batch option as well. (If you're planning to add this to a script, you'll also want to add in --no-tty and probably --yes.)

share|improve this answer
    
It's 1.4. using --batch has no effect. –  Omid Jan 4 '13 at 10:11
    
Sorry then @Nima. I don't know what to tell you. With GnuPG v1.4 you shouldn't need to do anything else to pass the passphrase in with either of those options. –  ryran Jan 4 '13 at 15:19
add comment

have you tried doing :

gpg --batch --passphrase-fd 0 --decrypt-files *.gpg
gpg --passphrase-fd 0 1234 file.gpg 

Source: Here

share|improve this answer
add comment
read -sp "Enter passphrase: " pass
echo "${pass}" | gpg --batch --no-tty --yes --passphrase-fd 0 --symmetric -o /path/to/saved/file.jpg.gpg /path/to/file.jpg
echo "${pass}" | gpg --batch --no-tty --yes --passphrase-fd 0 --decrypt -o /path/to/decrypted/file.jpg /path/to/encrypted/file.jpg.gpg
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.