gpg-agent, ssh keys, and systemd --user

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



How can I get gpg-agent to work with ssh keys? The following script that I’ve put in /etc/profile.d sets it up, but I’d like to move my user daemons (such as gpg-agent) over to systemd --user.

$ cat gpg-agent.sh
#!/bin/sh

envfile="${HOME}/.gnupg/gpg-agent.env"
if test -f "$envfile" && kill -0 $(grep GPG_AGENT_INFO "$envfile" | cut -d: -f 2) 2>/dev/null; then
    eval "$(cat "$envfile")"
else
eval "$(gpg-agent --daemon --enable-ssh-support --write-env-file "$envfile")"
fi
export GPG_AGENT_INFO

I’ve written the following user service, and it should do the same thing, but it doesn’t seem to work:

$ cat ~/.config/systemd/user/gpg-agent.service
[Unit]
Description=GnuPG private key agent
Wants=environment.target
Before=environment.target
IgnoreOnIsolate=true

[Service]
Type=forking
Environment=GPG_ENVFILE=%t/gpg-agent.info
ExecStart=/usr/bin/gpg-agent --daemon --enable-ssh-support --use-standard-socket --write-env-file ${GPG_ENVFILE} ExecStartPost=/bin/sh -c "xargs systemctl --user set-environment < ${GPG_ENVFILE}"
ExecStopPost=/bim/rm %t/gpg-agent.info
Restart=on-abort

[Install]
WantedBy=default.target

Both the script and the service file start gpg, create an environment file, and export the variables. But for some reason, gpg-agent doesn’t store keys or anything if run as a service. I don’t know why.

Can anyone help?



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]
  Powered by Linux