使用gpg从命令行加密文件



我希望加密我的文件"测试文件";对称加密。从我读到的帖子来看,使用"gpg"是Linux世界中最流行/最常见的方法。(我想确保我发送给的Linux用户不必安装更多的工具来解密文件(。

基于几篇帖子,我选择了"gpg",这应该很简单。但我得到的错误如下所示:

[root@mpserver tmp]# gpg --symmetric --passphrase "**KHns4621vHJG4**" testfile
gpg: problem with the agent: No pinentry
gpg: error creating passphrase: Operation cancelled
gpg: symmetric encryption of `testfile' failed: Operation cancelled
[root@myserver tmp]# gpg --version
gpg (GnuPG) 2.0.22
libgcrypt 1.5.3
Copyright (C) 2013 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
Supported algorithms:
Pubkey: RSA, ?, ?, ELG, DSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

我的命令出了什么问题?

GPG默认情况下不允许在命令行中使用密码短语。

您应该添加--batch --yes。比如:

gpg --batch --yes --symmetric --passphrase "**KHns4621vHJG4**" testfile

最新更新