升级2017-12-04。(添加--batch以防止出现密码提示)
您可能需要添加--batch
选项:
从的版本2开始GPG
,--batch
需要使用该选项以确保没有提示...确定,看起来:
$ gpg --version
gpg (GnuPG) 2.1.18
libgcrypt 1.7.6-beta
Copyright (C) 2017 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <https://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: /home/user /.gnupg
Supported algorithms:
Pubkey: RSA, ELG, DSA, ECDH, ECDSA, EDDSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2
试:
$ newdir=$(mktemp -d)
$ cd $newdir
$ seq 1 10 | gpg -c --batch --passphrase 1234 -o file.gpg -
$ ls -ltr
total 4
-rw-r--r-- 1 user user 91 Dec 4 15:42 file.gpg
$ hd file.gpg
00000000 8c 0d 04 07 03 02 ea fa d0 d3 2b 9a ea 06 df d2 |..........+.....|
00000010 4a 01 ed 50 74 ff 27 45 0e 6c 94 74 db e9 8a a5 |J..Pt.'E.l.t....|
00000020 03 9f 67 a0 73 97 e9 15 6b 56 a0 f0 88 71 85 a8 |..g.s...kV...q..|
00000030 dc 41 71 9f fa 3b f9 9d af ac 80 eb f4 f7 28 19 |.Aq..;........(.|
00000040 9f be 75 47 e6 d8 00 3e f6 60 f1 00 5e 63 57 ef |..uG...>.`..^cW.|
00000050 14 c3 4b 20 ff 94 03 03 c1 fc 98 |..K .......|
0000005b
听起来不错!现在好了:
$ gpg -d --batch --passphrase 1234 file.gpg
gpg: AES encrypted data
gpg: encrypted with 1 passphrase
1
2
3
4
5
6
7
8
9
10
尽管未提供任何-d
参数(语法与SO的问题相同),但解密后的数据将从file.gpg
中提取到new file
。
$ gpg --batch --passphrase 1234 file.gpg
gpg: WARNING: no command supplied. Trying to guess what you mean ...
gpg: AES encrypted data
gpg: encrypted with 1 passphrase
$ ls -ltr
total 8
-rw-r--r-- 1 user user 91 Dec 4 15:42 file.gpg
-rw-r--r-- 1 user user 21 Dec 4 15:44 file
$ cat file
1
2
3
4
5
6
7
8
9
10
这个工作很好!
$ cd -
$ rm -fR $newdir
$ unset newdir
gpg
运行正确的命令,而不是别名或包装程序吗?尝试/usr/bin/gpg --passphrase 1234 file.gpg
,type gpg
,gpg --version
和set | grep '^.\{0,9\}PG'