如何获取更多 gpg-agent 信息?

Mik*_*sta 4 gpg gpg-agent

按照 gpg 教程加密了 netrc 文件 。我编辑了我的

~/.profile
Run Code Online (Sandbox Code Playgroud)

像这样

if test -f $HOME/.gpg-agent-info && \
    kill -0 `cut -d: -f 2 $HOME/.gpg-agent-info` 2>/dev/null; then
    GPG_AGENT_INFO=`cat $HOME/.gpg-agent-info | cut -c 16-`
else
    # No, gpg-agent not available; start gpg-agent
    eval `gpg-agent --daemon --no-grab --write-env-file $HOME/.gpg-agent-info`
fi
export GPG_TTY=`tty`
export GPG_AGENT_INFO
Run Code Online (Sandbox Code Playgroud)

这是ls为了./gnupg

~/.gnupg$ ls
openpgp-revocs.d  private-keys-v1.d  pubring.kbx  pubring.kbx~  random_seed  trustdb.gpg
Run Code Online (Sandbox Code Playgroud)

它不起作用,当我重新启动 Ubuntu 时,会弹出错误消息,表明我已经有一个 gpg-agent 正在运行。如何检查并解决这个问题?

eval `gpg-agent --daemon --no-grab $HOME/.gpg-agent-info`
gpg-agent: a gpg-agent is already running - not starting a new one
Run Code Online (Sandbox Code Playgroud)

小智 10

~/.profile该教程已过时,您现在应该添加的只是GPG_TTY=$(tty).

在现代 Ubuntu 系统上,GPG 代理套接字已打开/run/user/$UID/gnupg,systemd 将gpg-agent在运行时自动启动gpg并尝试访问代理套接字。

为了确认这一点,gpgconf --list-dirs agent-socket将显示它用于套接字的路径,并且systemctl --user status gpg-agent应该显示已经运行的代理的状态。