我想编写一个脚本,使用 gpg 和保存在文件中的密码自动加密文件。
我试过这个:
gpg -c --passphrase-fd 0 file.txt < pass.txt
Run Code Online (Sandbox Code Playgroud)
当我在 Ubuntu 16.04 服务器上运行它时,它会按预期加密文件。当我在 Ubuntu 18.04 桌面上运行它时,它会使用密码管理器模式对话框要求我输入密码。
如何跳过该对话框并进行非交互式加密?
作为解决方法,我使用 openssl 而不是 gpg 执行此操作:
openssl aes-256-cbc -pass file:pass.txt -e -in file.txt -out file.txt.enc
Run Code Online (Sandbox Code Playgroud)
我在 Lubuntu 18.04 LTS 中进行了测试。
您的命令行对我来说失败了,与您描述的方式相同。
以下命令行对我有用,
gpg --batch -c --passphrase-file pass.txt file.txt
Run Code Online (Sandbox Code Playgroud)详情请参阅man gpg
Run Code Online (Sandbox Code Playgroud)--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 GnuPG version 1.x.
归档时间: |
|
查看次数: |
6291 次 |
最近记录: |