I have a headless Linux server running some services without root access (username leo
), via systemd --user
. I ssh into my server (as leo
), start the services, and then exit. The problem is, systemd sees that the last instance of leo
has logged out of the system and proceeds to stop all services owned by leo
.
I've discovered a workaround: running /usr/bin/ssh -t -N localhost
on the server every time I reboot the system and log in for the first time. A background ssh session keeps me logged in so the services do not disappear after I log out.
This is just that: a workaround. There has to be a proper, better way to do this, but I haven't figured it out. I'd like to do things properly if possible. Is there an officially supported way of staying logged in (via systemd) and if not, is there a more robust solution to this problem? (This will die if I restart sshd, for example.)