use*_*786 25 encryption appliance gnupg ubuntu-12.04
我正在尝试添加我的GPG公钥作为我们的设备安装过程的一部分.它的目的是加密任何重要文件,如管理员,然后使用管理门户将其拉入本地,然后使用私钥解密它们.计划是将公钥导出到文件中,并使用gpg --import命令进行设备安装过程以导入它.但我意识到,在进行任何加密之前,需要对密钥进行信任/签名.如何在安装时无需任何人为干预即可信任此密钥?顺便说一下,我们的设备操作系统是ubuntu vm,我们使用kickstart进行自动化.
感谢所有人的帮助.
Ray*_*Ray 14
你的问题实际上是"如果密钥不受信任,我如何在没有gpg的情况下加密密钥?"
一个答案是你可以签署密钥.
gpg --edit-key YOUR_RECIPIENT
sign
yes
save
Run Code Online (Sandbox Code Playgroud)
另一个是你可以告诉gpg继续并相信.
gpg --encrypt --recipient YOUR_RECIPIENT --trust-model always YOUR_FILE
Run Code Online (Sandbox Code Playgroud)
Joh*_*nny 12
通过使用--trust-model选项,有一种更简单的方法可以告诉 GPG 信任其所有密钥:
gpg -a --encrypt -r <recipient key name> --trust-model always
Run Code Online (Sandbox Code Playgroud)
从手册页:
--trust-model pgp|classic|direct|always|auto
Set what trust model GnuPG should follow. The models are:
always Skip key validation and assume that used
keys are always fully trusted. You generally
won't use this unless you are using some
external validation scheme. This option also
suppresses the "[uncertain]" tag printed
with signature checks when there is no evidence
that the user ID is bound to the key. Note that
this trust model still does not allow the use
of expired, revoked, or disabled keys.
Run Code Online (Sandbox Code Playgroud)
thi*_*ber 11
巧合的是我和OP有类似的情况 - 我正在尝试使用公钥/私钥来为不同的嵌入式设备签名和加密固件.由于还没有答案显示如何为您已导入的密钥添加信任,这是我的答案.
在测试机器上创建和测试密钥后,我将它们导出为ascii:
$ gpg --export -a <hex_key_id> > public_key.asc
$ gpg --export-secret-keys -a <hex_key_id> > private_key.asc
Run Code Online (Sandbox Code Playgroud)
然后安全复制并将它们导入构建服务器:
$ gpg --import public_key.asc
$ gpg --import private_key.asc
Run Code Online (Sandbox Code Playgroud)
现在编辑密钥以添加最终信任:
$ gpg --edit-key <user@here.com>
Run Code Online (Sandbox Code Playgroud)
在gpg>提示符下键入trust,然后键入5最终信任,然后y确认quit.
现在用测试文件测试它:
$ gpg --sign --encrypt --yes --batch --status-fd 1 --recipient "recipient" --output testfile.gpg testfile.txt
Run Code Online (Sandbox Code Playgroud)
报道
...
[GNUPG:] END_ENCRYPTION
Run Code Online (Sandbox Code Playgroud)
在没有增加信任的情况下,我得到了各种错误(不限于以下内容):
gpg: There is no assurance this key belongs to the named user
gpg: testfile.bin: sign+encrypt failed: Unusable public key
Run Code Online (Sandbox Code Playgroud)
小智 9
这对我有用:
尝试加密文件的响应如下:
gpg -e --yes -r <uid> <filename>
It is NOT certain that the key belongs to the person named
in the user ID. If you *really* know what you are doing,
you may answer the next question with yes.
Use this key anyway? (y/N)
That causes my shell script to fail.
Run Code Online (Sandbox Code Playgroud)
所以我:
$gpg --edit-key <uid>
gpg> trust
Please decide how far you trust this user to correctly verify other
users' keys (by looking at passports, checking fingerprints from
different sources, etc.)
1 = I don't know or won't say
2 = I do NOT trust
3 = I trust marginally
4 = I trust fully
5 = I trust ultimately
m = back to the main menu
Your decision? 5
Do you really want to set this key to ultimate trust? (y/N) y
Please note that the shown key validity is not necessarily correct
unless you restart the program.
gpg> quit
Run Code Online (Sandbox Code Playgroud)
现在加密工作正常。
添加trusted-key 0x0123456789ABCDEF到您的~/.gnupg/gpg.conf替换keyid.这相当于最终信任此密钥,这意味着它所做的认证将被接受为有效.只需将此密钥标记为有效而不信任它就更难,并且需要签名或将信任模型切换为直接.如果您确定只导入有效密钥,则可以通过添加将所有密钥标记为有效trust-model always.在后一种情况下,请确保禁用自动密钥检索(默认情况下不启用).
根据@tersmitten 的文章和一些反复试验,我最终使用了以下命令行来信任给定密钥环中的所有密钥,而无需用户交互。我将它用于与StackEschange Blackbox和hiera-eyaml-gpg一起使用的密钥:
# The "-E" makes this work with both GNU sed and OS X sed
gpg --list-keys --fingerprint --with-colons |
sed -E -n -e 's/^fpr:::::::::([0-9A-F]+):$/\1:6:/p' |
gpg --import-ownertrust
Run Code Online (Sandbox Code Playgroud)
就个人而言,我更喜欢将结果存储在 trustdb 文件本身的解决方案,而不是依赖于共享 Git 存储库之外的用户环境。
我想,我想出了办法做到这一点。我使用“gpg --import-ownertrust”将我的信任数据库导出到文本文件中,然后从中删除除我需要推送的公钥之外的所有密钥。然后将我的公钥和编辑的所有者信任文件导入到服务器上。这看起来像是工作。现在我在 Kickstart 文件中执行这些步骤时遇到问题:-(
| 归档时间: |
|
| 查看次数: |
34114 次 |
| 最近记录: |