如何在不输入密码的情况下签署rpm包?

时间:2018-05-09 16:36:04

标签: linux rpm gnupg

我正在尝试签署我使用GPG创建的RPM包而不输入密码,输入我可以签名的密码,但是没有输入密码就打开了消息框Please enter the passphrase to unlock the OpenPGP secret key,我需要密码不要在签署包时请求,因为这将是以“静默模式”执行的脚本。我可能有错误的命令,但我很难找到解决方案。

这是我试图执行的命令,即使这样,也要求输入密码:

gpg --batch --passphrase "78910" --clearsign test-1-0.x86_64.rpm

使用第二个命令,不要求输入密码:

echo "78910" | gpg --batch --passphrase-fd 0 --clearsign test-1-0.x86_64.rpm

但是,签名未执行并返回下述错误:

gpg: signing failed: Inappropriate ioctl for device gpg: /test-1-0.x86_64.rpm: clear-sign failed: Inappropriate ioctl for device

使用第三个命令,报告的错误不同:

echo "78910" | gpg --batch --passphrase-fd 0 ~/.gnupg/trustdb.gpg --clearsign test-1-0.x86_64.rpm

错误讯息:

gpg: Note: '--clearsign' is not considered an option gpg: WARNING: no command supplied. Trying to guess what you mean ... usage: gpg [options] [filename]

这是我创建gpg密钥的代码,我尝试创建没有密码,但是当密码值为空时我收到错误。

#!/bin/bash
echo "Key-Type: 1" > gen-key-script
echo "Key-Length: 1024" >> gen-key-script
echo "Subkey-Type: 1" >> gen-key-script
echo "Subkey-Length: 1024" >> gen-key-script}
echo "Name-Real: gpg test" >> gen-key-script
echo "Name-Email: test@test.com" >> gen-key-script
echo "Expire-Date: 0" >> gen-key-script
echo "Passphrase: 78910" >> gen-key-script
echo "" >> gen-key-script

#---------------------------------------------------------
# GENERATE THE KEY
#---------------------------------------------------------
gpg --batch --gen-key gen-key-script

#---------------------------------------------------------
# .RPMMACROS
#---------------------------------------------------------
echo "%_gpg_name gpg test <test@test.com>" > ~/.rpmmacros

2 个答案:

答案 0 :(得分:1)

如果您不想输入密码,则需要将私钥存储在磁盘上,而不受密码保护。这意味着每个有权访问密钥文件的人都可以签署您的软件包。决定你是否想要那个。

如果您不想保护密钥使用%no-protection,请执行以下操作:

echo "%no-protection" > gen-key-script
echo "Key-Type: 1" >> gen-key-script
echo "Key-Length: 1024" >> gen-key-script
echo "Subkey-Type: 1" >> gen-key-script
echo "Subkey-Length: 1024" >> gen-key-script
echo "Name-Real: gpg test" >> gen-key-script
echo "Name-Email: test@test.com" >> gen-key-script
echo "Expire-Date: 0" >> gen-key-script
echo "" >> gen-key-script

答案 1 :(得分:0)

如果您的GPG密码为空:

我知道这是一个较晚的答案,但是由于我没有GPG密码(空密码),因此对我来说效果最好。您可以实施一些技术来在CLI上安全地传递它,而无需键入它,无论如何,如果您有空口令,我认为这是一个很好的解决方案。

echo "" | setsid rpmbuild -bb --sign <filename>.spec"

来源:https://rpm-list.redhat.narkive.com/7hkHM9bp/signing-rpms-without-a-passphrase#post4