Keyring best practices with systemd

gnome-keyringkwalletsystemd

There plenty of tools working with keyrings: ssh-agent, gpg-agent, gnome-keyring, kwallet, wrappers like keychain, keyctl talking to GNU/Linux kernel. There are various recommendation on how/when to start it tailored for different environments.

This make it rather confusing. I'm using modern GNU/Linux distro with systemd and I start my user session with systemd –user as well. I expect this setup to last decades so I wonder what's the best way to get keyring into picture?

The main use-case is to store passwords from chromium/firefox in one consolidated place.

Shall I start keychain from my user shell autostart script (I use fish for interactive and dash as login shells if that matters)? Right now "gnome-keyring-daemon –daemonize –login" is spawned via PAM. Shall I start "gnome-keyring –start" from user systemd unit? Is there some dbus service which would start some keyring daemon upon first request?

The list of questions go on but you get the idea – what is the right way to get keyring-as-a-service?

Best Answer

On my machine (debian unstable) ssh-agent and gpg-agent have their own systemd user service/socket files. That means that they should be started when the user logs in or be activated when the first time an application is trying to access them.

Regarding gnome-keyring, there is (ATM?) no such systemd file and gnome-keyring is started both by PAM (as you mentioned) and by a .desktop file located in /etc/xdg/autostart/. The services located there should be started by your session manager (gnome-session, ...).

I see on debian a package called obsession that contains a /usr/bin/xdg-autostart I personally never used that tool, but that might help you to manually start the needed components if you are not using a session manager that supports XDG specification

Related Question