(Feeling a great temptation skip problem solution and root cause description but i am not such an evil person).
Beside lingering another item is required: user must be logged in through logind. This could be checked by typing
$ whoami
test
$ loginctl list-sessions
SESSION UID USER SEAT TTY
c15 1009 test pts/0
1 sessions listed.
but in my case i was seeing the following behavior
sh-5.1$ whoami
ssm-user
sh-5.1$ loginctl list-sessions
No sessions.
sh-5.1$ sudo su gitlab-runner
bash-5.1$ whoami
gitlab-runner
bash-5.1$ loginctl list-sessions
SESSION UID USER SEAT TTY
c16 0 root pts/0
1 sessions listed.
So basically, ssm console which is using ssm user does not using logind to log on. And switching user through sudo su creates a session for a root, not for a user you’re switching to.
TLDR:
To run user services you need
enable lingering via
loginctl enable-linger username
log as user either via
su username
or via normal ssh.
Running “sudo su username” will create dbus for root and will block you from running systemctl --user!!!