4

I followed encrypted netrc file with gpg tutorial. I edited my

~/.profile

like this

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

This is ls for ./gnupg

~/.gnupg$ ls
openpgp-revocs.d  private-keys-v1.d  pubring.kbx  pubring.kbx~  random_seed  trustdb.gpg

It does not work,when I restart my Ubuntu error pops up that I already have one gpg-agent running. How to check this and fix this?

eval `gpg-agent --daemon --no-grab $HOME/.gpg-agent-info`
gpg-agent: a gpg-agent is already running - not starting a new one
2
  • What are your Ubuntu and gnupg versions? Here (on Arch Linux, not Ubuntu) gpg-agent from gnupg 2.2.23 says that "--write-env-file" is an obsolete option - it has no effect
    – fra-san
    Oct 22, 2020 at 9:30
  • 1
    Could you maybe just use gpgconf --kill all first?
    – Kusalananda
    Oct 22, 2020 at 9:33

1 Answer 1

10

That tutorial is obsolete, and all you should add to your ~/.profile now is GPG_TTY=$(tty).

On a modern Ubuntu system, the GPG agent sockets are in /run/user/$UID/gnupg and systemd will start gpg-agent for you automatically when gpg runs and tries to access the agent socket.

To confirm this, gpgconf --list-dirs agent-socket will show you the path that it's using for the socket, and systemctl --user status gpg-agent should show the status of the already-running agent.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .