Since 2.1.17, users on machines with systemd will have their gpg-agent process launched automatically by systemd's user session, upon first access of any of the expected gpg-agent sockets (including the ssh socket). systemd will also cleanly tear this process down at session logout.
That is nice function, which you probably used before in archlinux, but it missing here, because no systemd...
...also, you need it manually:
0. not bad idea is set longer interval for GPG - as wrote above - just optional:
GPG can not directly be set to keep the password until restart, but you can change the time it caches the passwords to a very long time, e.g. a year. Add the following lines to $GNUPGHOME/gpg-agent.conf ($GNUPGHOME is usually ~/.gnupg):
default-cache-ttl 31536000
max-cache-ttl 31536000
This sets the time for caching passphrases to one year (31536000 seconds). default-cache-ttl is the normal caching time, which is reset when the key is used (so on each use it is cached longer), while max-cache-ttl limits the total time including extensions.
but you still need run gpg-agent as daemon to have same function as in systemd:
1. configure GnuPG to use an agent when appropriate. Edit ~/.gnupg/gpg.conf and add the following line:
use-agent
Now the system is almost ready to use the GPG agent. It is neccessary to restart the gpg-agent to take into account of the change in configuration:
gpg-connect-agent reloadagent /bye
2.Automatically starting the GPG agent - you can use it as sh script, put the lines in ~/.xinitrc if startx is used to start X.org or ~/.xsession if XDM, GDM, KDM, etc. are used. :
if [ -x /usr/bin/gpg-agent ]; then
eval "$(/usr/bin/gpg-agent --daemon)"
fi
similar for shutdown the agent, if needed:
if [ -n "${GPG_AGENT_INFO}" ]; then
kill $(echo ${GPG_AGENT_INFO} | cut -d':' -f 2) >/dev/null 2>&1
fi
4.You should always add the following lines to your .bashrc or whatever initialization file is used for all shell invocations:
GPG_TTY=$(tty)
export GPG_TTY
5. eventually you can set your SSH shh-agent in to .bashrc - if you need - too:
if ! pgrep -u "$USER" ssh-agent > /dev/null; then
ssh-agent > ~/.ssh-agent-thing
fi
if [[ "$SSH_AGENT_PID" == "" ]]; then
eval "$(<~/.ssh-agent-thing)"
fi