[systemd-devel] systemd + ssh-agent

Kok, Auke-jan H auke-jan.h.kok at intel.com
Mon Feb 18 18:06:43 PST 2013


On Mon, Feb 18, 2013 at 1:16 PM, Oleksii Shevchuk <alxchk at gmail.com> wrote:
> I use this (with pam_gnome_keyring):
>
>  > cat gnome-keyring-env.service
> [Unit]
> Description=Setup gnome keyring environment
>
> [Service]
> Type=oneshot
> ExecStart=/bin/sh -c "for env in $(gnome-keyring-daemon -s); do systemctl --user set-environment $env; done"
> ExecStop=/bin/sh -c "for env in GNOME_KEYRING_CONTROL SSH_AUTH_SOCK GPG_AGENT_INFO; do systemctl --no-block --user unset-environment $env; done"
> RemainAfterExit=yes
>
> [Install]
> WantedBy=env.target

an alternative for ssh-agent is to just run it statically as a service
with one location:

ssh-agent.service:
====
[Unit]
Description=SSH key agent

[Service]
Type=forking
Restart-on-failure
ExecStart=/usr/bin/ssh-agent -a %t/ssh-agent

[Install]
WantedBy=default.target
====

you'll have to run systemd --user with the following environment set
in the user-session at .service

>>>
Environment=SSH_AUTH_SOCK=%t/ssh-agent
<<<

that way, the agent should work at all times under a user session.

Auke


More information about the systemd-devel mailing list