1

I am using Ubuntu 16.04.2 LTS and currently trying out awesome window manager (I haven't customized the awesome config file yet and using the default one).

One of the thing that is not working for me is that the passpharse is currently not cached by gpg-agent.

I have done the following in .xsessionrc file,

# GnuPG agent (avoid repeatedly putting passphrase)
gnupglog="${HOME}/.gnupg/gpg-agent.info"
if (pgrep -u "${USER}" gpg-agent); then
  eval `cat ${gnupglog}`
  eval `cut -d= -f1 ${gnupglog} | xargs echo export`
else
  eval `gpg-agent --enable-ssh-support --daemon`
fi

I see that the agent has started. However, after running the command like gpg --decrypt FILE through terminal is not popping a UI dialog box and instead it is asking me a passphrase through the terminal. Also it is not cached.

The gnome keyring works perfectly if I use the default Unity dash. Can you please suggest the steps to get the gpg-agent working in awesome?

1

I found the root cause of the issue. gpg-agent should automatically set $GPG_AGENT_INFO during invocation but it is not setting the env variable. Similarly the file gpg-agent.info was not present as mentioned in the above post hence the above code wasn't working. As per the gpg documentation GPG_AGENT_INFO should point to the gpg-agent socket file followed by pid of gpg-agent and then the protocol (default 1). These three fields should be separated by colon.

So I put the following code in my ~/.profile to solve the issue (S.gpg-agent file is the socket file created by gpg-agent after it starts), Code:

if (pgrep -u "${USER}" gpg-agent); then
  export GPG_AGENT_PID=`pgrep -u ${USER} gpg-agent`
  export GPG_AGENT_INFO=${HOME}/.gnupg/S.gpg-agent:${GPG_AGENT_PID}:1
else
  eval `gpg-agent --enable-ssh-support --daemon`
  export GPG_AGENT_PID=`pgrep -u ${USER} gpg-agent`
  export GPG_AGENT_INFO=${HOME}/.gnupg/S.gpg-agent:${GPG_AGENT_PID}:1
fi

Still I am not sure why gpg-agent is not able to set GPG_AGENT_INFO.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.