gpg-agent can't be reached
10,366
Solution 1
Answering myself in case someone else is stuck on this.
On Ubuntu 16.04, the default versions are:
# gpg --version
gpg (GnuPG) 1.4.20
and
# gpg-agent --version
gpg-agent (GnuPG) 2.1.11
They are not compatible. It is mandatory to use GPG2:
# gpg2 --version
gpg (GnuPG) 2.1.11
Solution 2
The solution is to install gpgv2
:
sudo apt install gpgv2
This is because gpg-agent that comes with Ubuntu is version 2 and it tries to connect to gpg with version 2. But Ubuntu has gpg version 1 installed.
Related videos on Youtube
Author by
n1r3
Updated on September 18, 2022Comments
-
n1r3 over 1 year
On a fresh Ubuntu 16.04 install, I would like to use gpg to cypher my database backups, but I can't have the
gpg-agent
working.postgres@db:~$ gpg -s test.txt You need a passphrase to unlock the secret key for user: "Nicolas Remond <[email protected]>" 2048-bit RSA key, ID F5DECA47, created 2016-11-03 gpg: gpg-agent is not available in this session Enter passphrase:
Also, it seems that a gpg-agent is running as I did the following before:
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
And the gpg config has the
use-agent
setting:postgres@dbmaster0:~$ cat ~/.gnupg/gpg.conf | grep use-agent # For Ubuntu we now use-agent by default to support more automatic use-agent
What am I missing ?
-
Raniz over 7 yearsStart the agent with
--log-file [myfile]
and see if it gives you any errors in the log. -
n1r3 over 7 yearsThe right error message I have is
gpg: gpg-agent is not available in this session
. If I had a log how you suggest, all I have get is :2016-12-19 13:39:39 gpg-agent[10957] gpg-agent (GnuPG) 2.1.11 started
-
n1r3 over 7 yearsI tried to manually set
GPG_AGENT_INFO
, but I don't know how to know what to set ... that's when I got agpg: problem with the agent - disabling agent use
. -
n1r3 over 7 yearsAs root, setting
export GPG_AGENT_INFO=/var/lib/postgresql/.gnupg/S.gpg-agent:0:1
works, but not as a user. Also, it seems that I would have to do that manually, no? -
George Udosen over 7 yearsDid you add this GPG_TTY=$(tty) export GPG_TTY to your .bashrc file as stated in the _man gpg-agent page ?
-
David Foerster over 7 yearsCould you please check if you have an agent running for your user already with
pgrep -xu "$USER" gpg-agent
? What's the value of theGPG_AGENT_INFO
environment variable (check withecho "$GPG_AGENT_INFO"
)? Depending on the outcome I'll ask further questions. -
n1r3 over 7 years@George: Indeed, I did had it already
-
n1r3 over 7 years@DavidFoerster:
pgrep -xu "$USER" gpg-agent
gives me8572
and theGPG_AGENT_INFO
is empty, which I don't understand why? -
David Foerster over 7 yearsOk, that's a good start for an investigation. Let's make sure that
gpg-agent
can work at all. Please terminate the existing agent (pkill -xu "$USER" gpg-agent
), start a new one and have your shell “source” its output:eval $(gpg-agent --daemon)
. Then try to use the agent, e. g. withgpg -s some-file
. -
Elder Geek over 7 years
-
-
Dmitriusan about 6 yearsprobably you meant
gnupg2
-
phoxd about 3 yearsNo, it only worked after installing
gpgv2
. I tried withgnupg2
but it didn't work.