I am trying to run a user specific service with systemd. I am not an admin by profession but more a developer.
I am currently testing my solution on an Ubuntu 16.04 but plan to deploy the solution on Centos 7. I hope nothing will change really.
However until now I manage to do the following by script:
- check that my service is effectively running when launching by command line
- create the user john with a
/home/johndirectory (I need this home) but no password. I have read that it would be more secure (and hope I don't err...).
- create the directory
/home/john/.config/systemd/userto store my service files.
- Enable lingering according to this doc
So now I would like to test openning a session with john and start the services but is doesn't work. I am trying to do it the following:
sam$ sudo su - john john$ systemctl --user status my-service.service
and gather this unpleasant:
Failed to connect to bus: No such file or directory
and no matter
status/start/stop/list-units command I put in place of the status above it is always the same message.
The command that connect me to the session of john are logged by this line:
$journalctl -e Jun 15 18:16:23 sam-dell sudo: sam : TTY=pts/2 ; PWD=/home/sam/IdeaProjects ; USER=root ; COMMAND=/bin/su - john Jun 15 18:15:02 sam-dell su: Successful su for john by root Jun 15 18:15:02 sam-dell su: + /dev/pts/2 root:john Jun 15 18:15:02 sam-dell su: pam_unix(su:session): session opened for user john by (uid=0) Jun 15 18:15:02 sam-dell su: pam_systemd(su:session): Cannot create session: Already running in a session
...and nothing occurs when I am trying the
Note: I added a password to my user and it still not working from the terminal opened in my gnome session of my
But as my user has now a password, Ubuntu lets me connect to it with gnome and I could run the
systemctl --user status/start/stop without any problem by logging to the john gnome session.
Does anybody has an idea ? I am maybe taking the problem the wrong way, I simply want to run systemd service as another user on my remote server, so I suppose I was doing right but maybe not.
Many thanks for helping