我已经通过 Homebrew 使用
brew install gpg
安装了 GPG。
它安装在版本2.2.17
。
在我的 Maven POM 中,我有这个片段:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
但是运行时
mvn clean verify
我收到此错误:
gpg: Beglaubigung fehlgeschlagen: Inappropriate ioctl for device
gpg: signing failed: Inappropriate ioctl for device
如何修复此错误?
我已添加
GPG_TTY=$(tty)
export GPG_TTY
到我的
~/.bash_profile
文件。现在它正在工作。
另请参阅https://github.com/Homebrew/homebrew-core/issues/14737#issuecomment-309848851
在 macOS 上,您可能需要使用
pinentry-mac
来让 GUI 窗口输入 PIN 码,并可选择将 PIN 码存储在钥匙串中。
您可以通过 Homebrew 安装它:
brew install pinentry-mac
并在您的
~/.gnupg/gpg-agent.conf
配置中使用以下行启用它(如果不存在则创建它):
pinentry-program /usr/local/bin/pinentry-mac
试试这个
gpg --use-agent --armor --detach-sign --output $(mktemp) pom.xml
对我来说,发生这种情况是因为终端窗口不够大,无法容纳密码 TUI。一旦我打开一个更大的终端选项卡,然后重新运行 gpg 命令,我就能够看到密码终端用户界面。
如果有人在 bash 中输入
gpg
命令时收到此错误消息,请尝试添加 --no-tty
。这为我解决了问题。