In a recent Lubuntu 22.04 install, when running systemctl --user
with user 1000 I get:
❯ systemctl status --user
Failed to connect to bus: $DBUS_SESSION_BUS_ADDRESS and $XDG_RUNTIME_DIR not defined (consider using --machine=<user>@.host --user to connect to bus of other user)
❯ eval $(dbus-launch --sh-syntax)
❯ systemctl status --user
Failed to read server status: Process org.freedesktop.systemd1 exited with status 1
However, when using another user (1001), or the same user, via su $user
, systemctl status --user
works just fine.
Data:
- When the user 1001 has an active tty session (via
su
,ls /run/user
shows1001
andsystemctl status user-1001.slice
shows it active. journalctl -u user-1000.slice
shows no errors.- The problem is the same for newly created users.
- Is user 1000 is 'delta', executing
su delta
(from delta's ssh session), and thensystemclt --user
, all works. Somehow,su
creates the needed environment, but not ssh.
What else can I do to debug the problem? Can I restore systemd status config to a fresh state?, or copy something from 1002 to 1001?
echo $XDG_RUNTIME_DIR $UID $DBUS_SESSION_BUS_ADDRESS
? It sounds like yoursshd
is not setting up your environment. Trymachinectl login .host
(from thesystemd-container
package) – Stewart Feb 06 '23 at 13:39