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

我正在尝试使用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


慕尼黑8549860
浏览 423回答 2
2回答

忽然笑

如果您不想输入密码,则需要将私钥存储在磁盘上,而不受密码保护。这意味着有权访问密钥文件的每个人都可以对您的软件包进行签名。确定是否需要。如果您不想保护密钥的使用%no-protection,例如:echo "%no-protection" > gen-key-scriptecho "Key-Type: 1" >> gen-key-scriptecho "Key-Length: 1024" >> gen-key-scriptecho "Subkey-Type: 1" >> gen-key-scriptecho "Subkey-Length: 1024" >> gen-key-scriptecho "Name-Real: gpg test" >> gen-key-scriptecho "Name-Email: test@test.com" >> gen-key-scriptecho "Expire-Date: 0" >> gen-key-scriptecho "" >> gen-key-script
打开App,查看更多内容
随时随地看视频慕课网APP