5

I'm connected to a google compute instance via ssh with Debian 9. When I try any systemctl --user ... command (systemctl --user status for instance) I get an error: "Failed to connect to bus: No such file or directory".

I have tried setting XDG_RUNTIME_DIR=/run/user/$(id -u) and noticed that no directory in /run/user is created.

I also installed dbus apt install dbus and ensured dbus.service is running (it was not installed originally).

The sshd_config by default has UsePAM yes.

3 Answers 3

4

Solved with:

sudo apt install --reinstall libpam-systemd

which installed new packages: dbus, libdbus-1-3

After logout/login systemctl --user status and other "systemctl --user" commands work. No need to set "XDG_RUNTIME_DIR".

1
  • The trick was to reinstall libpam-systemd. This is the only answer that fixes this error in Debian 12. Commented Sep 27, 2023 at 2:46
1

I had a similar problem restarting pipewire service and the solution was to drop sudo in front of systemctl. https://gitlab.freedesktop.org/pipewire/pipewire/-/issues/1608

0

Enabling lingering helped me in your situation:

$ loginctl enable-linger $USER

Now I can see my user's $XDG_RUNTIME_DIR being created and used:

$ ls -lant $XDG_RUNTIME_DIR
total 0
drwxr-xr-x 6 1177 1177 160 Aug  5 11:36 systemd
drwx------ 8 1177 1177 220 Aug  5 11:36 .
drwx------ 3 1177 1177  60 Aug  5 11:36 dbus-1
drwx------ 3 1177 1177  60 Aug  5 11:33 containers
drwx-----T 2 1177 1177  40 Aug  5 11:33 libpod
drwx------ 2 1177 1177 140 Aug  5 11:33 gnupg
srw-rw-rw- 1 1177 1177   0 Aug  5 11:33 pk-debconf-socket
drwxr-xr-x 2 1177 1177  60 Aug  5 11:33 podman
srw-rw-rw- 1 1177 1177   0 Aug  5 11:33 snapd-session-agent.socket
srw-rw-rw- 1 1177 1177   0 Aug  5 11:33 bus
drwxr-xr-x 3    0    0  60 Aug  5 11:33 ..

Credit goes to this suggestion from podman's sumptuous warning message:

$ podman run -u 1177 ubuntu bash -c "whoami"
WARN[0000] The cgroupv2 manager is set to systemd but there is no systemd user session available 
WARN[0000] For using systemd, you may need to login using an user session 
WARN[0000] Alternatively, you can enable lingering with: `loginctl enable-linger 1177` (possibly as root) 
WARN[0000] Falling back to --cgroup-manager=cgroupfs    
WARN[0000] The cgroupv2 manager is set to systemd but there is no systemd user session available 
WARN[0000] For using systemd, you may need to login using an user session 
WARN[0000] Alternatively, you can enable lingering with: `loginctl enable-linger 1177` (possibly as root) 
WARN[0000] Falling back to --cgroup-manager=cgroupfs    
1177

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .