I'm trying to set up a user scope service after logging in via SSH, but when I try setting anything up like..

systemctl --user enable wallpaper.timer

I get these errors, even though I'm logged in via SSH as the user in question..

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)

env confirms those particular environment variables are not set. But the following works for some reason.

sudo systemctl --machine=<user>@.host --user enable wallpaper.timer

which is annoying and seems roundabout. I have to sudo to get access to my own user environment variables. Right now, I don't see the point in setting up services this way over just using root services and setting User=<username>.

How can I log into SSH user account and have $XDG_RUNTIME_DIR and $DBUS_SESSION_BUS_ADDRESS set? I've tried ssh and ssh -t with same results.

1 Answer 1


$XDG_RUNTIME_DIR and $DBUS_SESSION_BUS_ADDRESS were not being set when logging in via SSH because I had turned off PAM system in the host's SSH server configuration.

sudo nano /etc/ssh/sshd.config

and setting

UsePAM yes

fixed it.

Apparently, it is the PAM system that controls these variables.

You must log in to answer this question.

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