Re: systemd-user, daemons, and ssh sessions
On Sun, 26 Jul 2026 at 16:23:06 +1000, Russell Coker wrote:
Currently we have the X login programs (sddm, gdm3, and probably others) using
systemd to create a session via /etc/pam.d/common-session which if there is a
typical desktop environment installed includes pipewire and on a laptop it
will include Bluetooth. While it is easy to imagine some uncommon situations
where those things could be useful for X login (bluetooth keyboard? audio
screen reader?) in most cases it won't be needed.
In the cases where these things *are* needed (like a machine whose only
keyboard/mouse/input devices happen to be connected via Bluetooth, or a
machine whose main user needs a screen reader and therefore audio), they
are not just useful, they are essential, so a universal operating system
will tend to need to err on the side of them being enabled.
For ssh on a system where you have a desktop environment installed all the
desktop programs that are started by systemd-user are run on a ssh login by
default.
By "desktop programs", do you mean per-user services that don't require
a desktop environment or a graphical session? Like `dbus-daemon
--session`, which is a communication mechanism that per-user things can
use to talk to each other, and has nothing that inherently requires a
GUI?
For some user-services (generally "infrastructure" ones like the
dbus-daemon), it's intentional that they run in all login sessions,
whether those sessions are graphical, ssh, getty/login or something
else. Historically, the dbus-x11 package had the bug that D-Bus was only
available in graphical sessions, because there was no good way to scope
the `dbus-daemon --session` instance to the lifetime of a session.
One of the purposes of dbus-user-session is to fix that bug.
For other user-services, if they genuinely only make sense to run inside
a graphical session, ideally they could have
WantedBy=graphical-session.target or
WantedBy=graphical-session-pre.target instead of WantedBy=default.target
in the "[Install]" sections of their systemd service files. Some
services like gnome-keyring already do this. (But beware of assuming
that something is never useful for non-graphical sessions just because
*you* don't use it in non-graphical sessions!)
Unfortunately, many of our graphical desktop environments don't interact
with graphical-session{,-pre}.target - I know that GNOME and KDE Plasma
do, but many others don't - and so far I haven't been able to find good
documentation with practical advice on a minimal level of integration
for desktop environment implementors. As a result, there is no
particularly good way for the systemd infrastructure to choose different
sets of services for a non-graphical session (ssh or getty/login), vs. a
graphical session like e.g. MATE that doesn't start
graphical-session.target. This leads many developers of
non-desktop-environment-specific services to connect them to
default.target instead, because that's the only thing that'll work in
all GUI environments. If someone wants to work on addressing that
(documenting what's expected better, and/or implementing that in other
desktop environments) then that would be very useful, and would also fix
some issues seen in e.g. xdg-desktop-portal.
Other user-services are started on-demand when first used, by D-Bus
activation or socket activation or some similar protocol. If those are
starting unexpectedly, it means something in your session is trying to
interact with them, and the route to follow would be to find out what is
interacting with those services, and if appropriate, make it not do
that. For example, for D-Bus services, the reference dbus-daemon logs a
message to the systemd Journal every time it carries out activation
(starting a service on-demand), which mentions which program sent the
message that requested activation.
smcv
Re: systemd-user, daemons, and ssh sessions
Moin On Sun, Jul 26, 2026 at 04:23:06PM +1000, Russell Coker wrote: > Currently we have the X login programs (sddm, gdm3, and probably others) > using > systemd to create a session via /etc/pam.d/common-session which if there is a > typical desktop environment installed includes pipewire and on a laptop it > will include Bluetooth. While it is easy to imagine some uncommon situations > where those things could be useful for X login (bluetooth keyboard? audio > screen reader?) in most cases it won't be needed. gdm3 tears down unused greeter sessions within a minute. So no, this does not run unused. Both bluetoothd (which runs outside of the user session as root anyway) and pipewire are required for a useful greeter. > Should we make it a standard practice to have configuration options for this > to allow the sysadmin to easily choose whether sddm/gdm3/whatever starts such > things? It shouldn't be THAT difficult for a sysadmin to put in symlinks in > the account configuration for sddm to make it not start such things, but it's > also not particularly easy. No, as at least gdm3 does not start anything, but just sets up a systemd user session for the greeter. > For ssh on a system where you have a desktop environment installed all the > desktop programs that are started by systemd-user are run on a ssh login by > default. For a single user system this works well. For a system that many > developers ssh to but which has an X login at the console either for people > to > control it via GUI tools or because it's the default and no-one uninstalled > those things you end up with every developer having a bunch of programs that > they never use running all the time. systemd-user runs once for a user, but logins (ssh or local) cen be multiple. So how would you distinguish that? > For ssh it would be good to have options to easily disable user units at a > default level (maybe in /etc/skel) and also have a good way of disabling > systemd in pam for a single daemon. Sure you could edit /etc/pam.d/sshd to > not include common-auth and then paste in the bits of common-auth you > actually > want but that's ugly and will risk errors on upgrades. > What do you think? I fail to see a goal. Maybe describe that first. And no, excluding pam_systemd will break a lot of stuff. You can try this yourself by logging into a user with uid between 1 and 999, which are excepted from user session. Bastian -- Most legends have their basis in facts. -- Kirk, "And The Children Shall Lead", stardate 5029.5
Re: systemd-user, daemons, and ssh sessions
On Monday, 27 July 2026 00:16:08 AEST Aaron Rainbolt wrote: > > For ssh it would be good to have options to easily disable user units at a > > default level (maybe in /etc/skel) and also have a good way of disabling > > systemd in pam for a single daemon. Sure you could edit /etc/pam.d/sshd > > to > > not include common-auth and then paste in the bits of common-auth you > > actually want but that's ugly and will risk errors on upgrades. > > I'm not sure what "disabling systemd in pam" means? If you mean that > an SSH login session won't be a "real" login session, that seems like > a distinctly bad idea because it will mess with Polkit's idea of how > the user is logged into the system (which will in turn affect what > Polkit will and won't allow the user to do). I mean have sshd work the way it used to work before systemd pam support was written. If that's not an option then it means there's more reason to have better control of systemd-user units. -- My Main Blog http://etbe.coker.com.au/ My Documents Bloghttp://doc.coker.com.au/
Re: systemd-user, daemons, and ssh sessions
On Sun, Jul 26, 2026 at 1:39 AM Russell Coker wrote: > > Currently we have the X login programs (sddm, gdm3, and probably others) using > systemd to create a session via /etc/pam.d/common-session which if there is a > typical desktop environment installed includes pipewire and on a laptop it > will include Bluetooth. While it is easy to imagine some uncommon situations > where those things could be useful for X login (bluetooth keyboard? audio > screen reader?) in most cases it won't be needed. > > Should we make it a standard practice to have configuration options for this > to allow the sysadmin to easily choose whether sddm/gdm3/whatever starts such > things? It shouldn't be THAT difficult for a sysadmin to put in symlinks in > the account configuration for sddm to make it not start such things, but it's > also not particularly easy. What do you propose these configuration options look like, and where will they be stored? (Ideally there should be a mechanism for Debian to ship one set of configs, derivatives to override those, and administrators to in turn override those.) > For ssh on a system where you have a desktop environment installed all the > desktop programs that are started by systemd-user are run on a ssh login by > default. For a single user system this works well. For a system that many > developers ssh to but which has an X login at the console either for people to > control it via GUI tools or because it's the default and no-one uninstalled > those things you end up with every developer having a bunch of programs that > they never use running all the time. > > For ssh it would be good to have options to easily disable user units at a > default level (maybe in /etc/skel) and also have a good way of disabling > systemd in pam for a single daemon. Sure you could edit /etc/pam.d/sshd to > not include common-auth and then paste in the bits of common-auth you actually > want but that's ugly and will risk errors on upgrades. I'm not sure what "disabling systemd in pam" means? If you mean that an SSH login session won't be a "real" login session, that seems like a distinctly bad idea because it will mess with Polkit's idea of how the user is logged into the system (which will in turn affect what Polkit will and won't allow the user to do). > What do you think? As long as "everything" is started by default and one has to blacklist what they don't want, I don't see a problem with that. If whitelisting is desirable for some users, a "whitelist" mode that has to be explicitly turned on might also be useful. -- Aaron > -- > My Main Blog http://etbe.coker.com.au/ > My Documents Bloghttp://doc.coker.com.au/ > > >

