在一个全新的Ubuntu 16.04安装中,我想使用gpg来加密我的数据库备份,但是我无法让gpg-agent工作。
而且gpg配置中有"use-agent"设置:
我错过了什么?
postgres@db:~$ gpg -s test.txt
You need a passphrase to unlock the secret key for
user: "Nicolas Remond <nicolas@xxx.com>"
2048-bit RSA key, ID F5DECA47, created 2016-11-03
gpg: gpg-agent is not available in this session
Enter passphrase:
另外,似乎有一个gpg-agent正在运行,因为我之前做了以下操作:
postgres@db:~$ gpg-agent
gpg-agent[1715]: no gpg-agent running in this session
postgres@db:~$ gpg-connect-agent /bye
gpg-connect-agent: no running gpg-agent - starting '/usr/bin/gpg-agent'
gpg-connect-agent: waiting for the agent to come up ... (5s)
gpg-connect-agent: connection to agent established
postgres@db:~$ pidof gpg-agent
1762
而且gpg配置中有"use-agent"设置:
postgres@dbmaster0:~$ cat ~/.gnupg/gpg.conf | grep use-agent
# For Ubuntu we now use-agent by default to support more automatic
use-agent
我错过了什么?
--log-file [myfile]
启动代理,并查看日志中是否有任何错误信息。 - Ranizgpg: gpg-agent在此会话中不可用
。如果我按照您的建议记录日志,我所得到的只有:2016-12-19 13:39:39 gpg-agent[10957] gpg-agent (GnuPG) 2.1.11已启动
。 - n1r3GPG_AGENT_INFO
,但是我不知道应该设置什么...这就是当我遇到gpg: problem with the agent - disabling agent use
时的情况。 - n1r3export GPG_AGENT_INFO=/var/lib/postgresql/.gnupg/S.gpg-agent:0:1
是有效的,但对于普通用户则不行。此外,看起来我需要手动执行这个操作,是吗? - n1r3pgrep -xu "$USER" gpg-agent
命令检查一下您的用户是否已经运行了代理?GPG_AGENT_INFO
环境变量的值是多少(使用echo "$GPG_AGENT_INFO"
命令进行检查)?根据结果,我会进一步提出问题。 - David Foersterpgrep -xu "$USER" gpg-agent
返回结果为8572
,而GPG_AGENT_INFO
是空的,这让我感到困惑,不知道是为什么? - n1r3gpg-agent
可以正常工作。请终止现有的代理(pkill -xu "$USER" gpg-agent
),启动一个新的,并让您的shell“来源于”它的输出:eval $(gpg-agent --daemon)
。然后尝试使用代理,例如gpg -s some-file
。 - David Foerster