1

I created a user that run timers and service with systemctl --user. When I try to login via ssh, I have no issue with systemctl --user. But when I connect to this user with su, I have a bus error:

me@some_host / $ sudo su -l some_user -                       
some_user@some_host / $ systemctl --user status a_random.service
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)

Then I tried this:

me@some_host / $ systemctl --machine=some_user@.host --user status a_random.service               
Cannot access user instance remotely.

I am running this on Debian. I think it as to do with pam.dbut not sure. Any idea on how to solve this?

AdminBee
  • 22,803
Ricain
  • 141

1 Answers1

1

I solved this with adding custom XDG_RUNTIME_DIR variable into my .bashrc

In order to do that I first identified my UID:

$ echo $UID
1002

And then I create my variable:

$ export XDG_RUNTIME_DIR="/run/user/1002"

Adding this last command into my .bashrc made this persistent. And voila! :)

Ricain
  • 141